Highlighting buried treasure in Twisted

Feb 07, 2008 05:17

I've previously blogged about twisted.python.modules, but it assumes you know about another API inside Twisted, twisted.python.filepath.  Unfortunately this module is rather under-documented and under-publicized, despite being extremely useful.  Unlike a lot of Twisted, much of the code in twisted.python can be extracted and used by itself, ( Read more... )

Leave a comment

Comments 6

Nice Write-up :-) oubiwann February 13 2008, 18:04:35 UTC
I've been thinking about sharing the goodness that is FilePath for a few months -- now I don't have to :-) Using it has saved me sooo much time...

Reply


Please convince Guido to make this part of the standard library djfroofy February 14 2008, 21:29:54 UTC
I mostly agree. twisted.python.filepath provides an great API and testability is important. The only functionality I wish FilePath.walk provided was the ability to stop recursion at certain points, like os.walk provides you:

if '.svn' in dirs:
dirs.remove('.svn')

Maybe this could be as simple as a keyword argument to walk:

fp.walk(exclude=['.svn','evil_symlink2root'])

Reply

Re: Please convince Guido to make this part of the standard library glyf February 15 2008, 02:14:00 UTC
Submit a patch! :) This sounds straightforward / well specified enough I'll even commit to a review... (However, something that lets you actually modify the iteration would be better than something that took static strings.)

As far as getting into the stdlib - agitate on python-dev. I'll help you do any necessary coding if you can do the legwork to get everyone to agree that it's desirable (as opposed to one of the 30 "OO" filesystem wrappers that people have written for the stdlib, or nothing at all). I don't have the energy for that.

Reply

Re: Please convince Guido to make this part of the standard library djfroofy February 20 2008, 16:45:38 UTC
I don't have the energy to agitate on python-dev either nor do I have the required diplomacy skills ;) Anyhow, here's the patch:

http://twistedmatrix.com/trac/attachment/ticket/3044/filepath.py.diff#preview

Reply


too much coupling zooko March 4 2008, 17:02:01 UTC
This kind of thing makes me sad ( ... )

Reply

Re: too much coupling glyf March 4 2008, 20:32:57 UTC
there are comparable packages which twisted could use in order to gain the benefit without the cost of maintaining the package
Not true, as far as I'm aware. I believe you're talking about the many "object oriented" path abstractions for Python. Twisted uses FilePath for two main requirements, neither of which is OO nicety: security in contexts like a web server, and polymorphism to zip files. Do any of the path libraries you're talking about implement either of these requirements?Frankly, suggesting that people could copy a few source files is the kiss of death, for the prospect of that code being re-used by other people.
This is exactly the strategy that the module being considered for inclusion in Python under PEP 355 uses.Twisted doesn't use good packaging technology
Python doesn't have any good packaging technology. distutils is sparsely documented and difficult to do anything with without touching internal implementation details; setuptools is a mine-field unless your sys.path is set up exactly like PJE's. Granted, Twisted's ( ... )

Reply


Leave a comment

Up