Re: [Twisted-web] documentation -- Techno Turkey's fifth adventure
![](https://secure.gravatar.com/avatar/2829e7f709de61c15d69a67c8d22109d.jpg?s=120&d=mm&r=g)
Hi Folks, Sounds like I kicked off a vital and worthy discussion with my questions/request re: development environment. Very exciting! My instincts tell me that it'w worth letting this discussion run it's course for another couple of days until we arrive at a consensual plan-of-attack. Best I can contribute is a summery of suggestions to date: Development Environment: -- Valentino suggests we take a look at:
An alternative for Nevow is using Combinator (explained in the Divmod Combinator page): http://divmod.org/trac/wiki/DivmodCombinator Another alternative for Nevow is using setuptools although I'm unsure how working itis. Yet another for both is using .pth
Twisted Coding Standards -- Valentino also suggests we review:
http://twistedmatrix.com/projects/core/documentation/howto/policy/coding-sta...
-- glyph suggests: There is actually an under-maintained Axiomatic plugin in Mantissa which helps with this somewhat; it probably doesn't work at the moment, but check out "axiomatic mantissa". It might help with this kind of setup, or at least provide some ideas for tools to expedite the turkey's adventures. Directory Structure -- Daniel says:
While you are correct that no specific directory layout conventions have been blessed by the core development team, I think that there is a lot of value in providing one, if only to give really new users some kind of structural anchor point from which to begin learning web-app development with twisted.
(Speaking for the turkey contingent, I heartily agree.) -- Daniel suggests: /ProjectName /packagename /static /css /js /images module1.py module2.py ... -- Valentino counters: /ProjectName /static /i - images /s - styles /j - javascript /template /doc /database - sql files /bin - various scripts /projectname - python modules /web - for the web stuff /storage - for the data layer /other_eventual_twisted_using_subparts common_python_modules.py -- Manlio asks:
An interesting question is: when one should consider the option of serving static content with a server like lighttpd, and forward with mod_proxy requests for dynamic content to twisted web?
static.File is a no match versus lighttpd, but there is the overhead of mod_proxy and one should also consider how to design the site layout at the best.
.pth vs. PATH -- Daniel says:
I suggest using .pth files rather than path variables. Using .pth files should "just work" regardless of your OS, and not require any fiddling around with the environment by hand.
So, basically, for a new web project, you'd create your project dirs, and then stick a "myproject.pth" file in the site-packages directory, containing "/path/to/my/project/topmost/folder"
Testing development environment
To test that the dev environment is set up correctly, I'd just start up a python interpreter prompt and import twisted, then import nevow, and lastly, import myprojectpackage.
Running Twisted code -- Daniel suggests:
I probably sound like a broken record, but I'd suggest offering one, and only one, way to run the code, so that users aren't fiddling with things that are not central to grasping the concepts being presented.
Me, I use .tac files for everything these days, so that's what I would recommend for use within the tutorials.
Seems to me that these are all open questions worth consideration and further discussion and clarification. As soon as we have some degree of mutual understanding and concensus, we can discuss how to implement the Turkey's Guide for Diving into Twisted or whatever we decide to call it, as well as where to put it. Meanwhile... I'll post the next draft of Dialtone's Resource Magic on http://twisted.paisite.com, incorporating suggested changes. Many many thanks to all. Best wishes, Lloyd
![](https://secure.gravatar.com/avatar/2829e7f709de61c15d69a67c8d22109d.jpg?s=120&d=mm&r=g)
Hello, I've added Turkey's fifth adventure, "Dialtone's Resource Magic" to http://twisted.paisite.com And I've brought up my Twisted environment to test it. (Questions about this later). When I run twistd -noy ResourceMagic.py, I get the following error on line 1: "Failed to load application: No module named zope.interface" I'm running Debian Sarge. I loaded both Twisted and Nevow through Debian's Synaptic. Is there something else I need to load? Or what am I missing and how do I fix it? Or, maybe it's a configuration problem. The code is at /home/tt/Adventures/bin. I have a ttAdventures.pth file at /usr/local/lib/python2.3/site-packages with the content: /home/tt/Adventures/bin Can this be my problem? Clue: If I execute twistd -noy ResourceMagic.py in /home/tt/Adventures, I get the following error: "Failed to load application: [Errno 2] No such file or directory: 'ResourceMagic.py'" Also, it'd be helpful if a couple of people could review/proofread/test "Dialtone's Resource Magic" in http://twisted.paisite.com to affirm that all is correct and clear. I'll continue to test the code once I get past this zope.interface problem. Many thanks, Lloyd
![](https://secure.gravatar.com/avatar/10aa56aec887e973085025c6ddfdc46b.jpg?s=120&d=mm&r=g)
On Thu, 27 Jul 2006 13:23:00 -0400 (EDT), lloyd@paisite.com wrote:
Hello,
I've added Turkey's fifth adventure, "Dialtone's Resource Magic" to http://twisted.paisite.com
Very cool.
"Failed to load application: No module named zope.interface"
This is right. Nevow and the new Twisted do require zope.interface to work. It's is present in all ubuntu configurations and I think also debian's. If it's not there you can get it here: http://www.zope.org/Products/ZopeInterface
"Failed to load application: [Errno 2] No such file or directory: 'ResourceMagic.py'"
Yes, twistd doesn't import the file, only loads it and executes it, even if it is in the path it won't be loaded. That's why it is also better to name it with the tac suffix instead of the py suffix so that people won't believe it's importable.
Also, it'd be helpful if a couple of people could review/proofread/test "Dialtone's Resource Magic" in http://twisted.paisite.com to affirm that all is correct and clear. I'll continue to test the code once I get past this zope.interface problem.
I'll give it a look later.
![](https://secure.gravatar.com/avatar/2829e7f709de61c15d69a67c8d22109d.jpg?s=120&d=mm&r=g)
Hi Valentino, On Thu, July 27, 2006 1:38 pm, Valentino Volonghi aka Dialtone wrote:
This is right. Nevow and the new Twisted do require zope.interface to work. It's is present in all ubuntu configurations and I think also debian's.
I've loaded python2.3-zopeinterface from Debian repository and, in my devel system, have renamed ResourceMagic.py ResourceMagic.tac. Now when I run twistd -noy ResourceMagic.tac I get the error shown below. Can't figure out how to track it down. Thanks, Lloyd 2006/07/28 15:29 EDT [-] Log opened. 2006/07/28 15:29 EDT [-] twistd 1.3.0rc1 (/usr/bin/python2.3 2.3.5) starting up 2006/07/28 15:29 EDT [-] reactor class: twisted.internet.default.SelectReactor 2006/07/28 15:29 EDT [-] Loading ResourceMagic.tac... 2006/07/28 15:29 EDT [-] Traceback (most recent call last): 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/twisted/application/app.py", line 123, in getApplication 2006/07/28 15:29 EDT [-] application = service.loadApplication(filename, style, passphrase) 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/twisted/application/service.py", line 319, in loadApplication 2006/07/28 15:29 EDT [-] application = sob.loadValueFromFile(filename, 'application', passphrase) 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/twisted/persisted/sob.py", line 213, in loadValueFromFile 2006/07/28 15:29 EDT [-] exec data in d, d 2006/07/28 15:29 EDT [-] File "<string>", line 11, in ? 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/zope/interface/advice.py", line 132, in advise 2006/07/28 15:29 EDT [-] return callback(newClass) 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 550, in _implements_advice 2006/07/28 15:29 EDT [-] classImplements(cls, *interfaces) 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 527, in classImplements 2006/07/28 15:29 EDT [-] spec.declared += tuple(_normalizeargs(interfaces)) 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 1345, in _normalizeargs 2006/07/28 15:29 EDT [-] _normalizeargs(v, output) 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 1344, in _normalizeargs 2006/07/28 15:29 EDT [-] for v in sequence: 2006/07/28 15:29 EDT [-] TypeError: iteration over non-sequence 2 traceback... ...bunch of stuff... File "/usr/lib/python2.3/site-packages/zope/interface/advice.py", line 132, in advise return callback(newClass) File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 550, in _implements_advice classImplements(cls, *interfaces) File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 527, in classImplements spec.declared += tuple(_normalizeargs(interfaces)) File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 1345, in _normalizeargs_normalizeargs(v, output) File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 1344, in _normalizeargs for v in sequence: exceptions.TypeError: iteration over non-sequence Failed to load application: iteration over non-sequence
![](https://secure.gravatar.com/avatar/7ed9784cbb1ba1ef75454034b3a8e6a1.jpg?s=120&d=mm&r=g)
On Fri, 28 Jul 2006 15:42:44 -0400 (EDT), lloyd@paisite.com wrote:
Hi Valentino,
On Thu, July 27, 2006 1:38 pm, Valentino Volonghi aka Dialtone wrote:
This is right. Nevow and the new Twisted do require zope.interface to work. It's is present in all ubuntu configurations and I think also debian's.
I've loaded python2.3-zopeinterface from Debian repository and, in my devel system, have renamed ResourceMagic.py ResourceMagic.tac.
Now when I run twistd -noy ResourceMagic.tac I get the error shown below. Can't figure out how to track it down.
Thanks,
Lloyd
2006/07/28 15:29 EDT [-] Log opened. 2006/07/28 15:29 EDT [-] twistd 1.3.0rc1 (/usr/bin/python2.3 2.3.5) starting up 2006/07/28 15:29 EDT [-] reactor class: twisted.internet.default.SelectReactor 2006/07/28 15:29 EDT [-] Loading ResourceMagic.tac... 2006/07/28 15:29 EDT [-] Traceback (most recent call last): 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/twisted/application/app.py", line 123, in getApplication 2006/07/28 15:29 EDT [-] application = service.loadApplication(filename, style, passphrase) 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/twisted/application/service.py", line 319, in loadApplication 2006/07/28 15:29 EDT [-] application = sob.loadValueFromFile(filename, 'application', passphrase) 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/twisted/persisted/sob.py", line 213, in loadValueFromFile 2006/07/28 15:29 EDT [-] exec data in d, d 2006/07/28 15:29 EDT [-] File "<string>", line 11, in ? 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/zope/interface/advice.py", line 132, in advise 2006/07/28 15:29 EDT [-] return callback(newClass) 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 550, in _implements_advice 2006/07/28 15:29 EDT [-] classImplements(cls, *interfaces) 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 527, in classImplements 2006/07/28 15:29 EDT [-] spec.declared += tuple(_normalizeargs(interfaces)) 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 1345, in _normalizeargs 2006/07/28 15:29 EDT [-] _normalizeargs(v, output) 2006/07/28 15:29 EDT [-] File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 1344, in _normalizeargs 2006/07/28 15:29 EDT [-] for v in sequence: 2006/07/28 15:29 EDT [-] TypeError: iteration over non-sequence 2
traceback... ...bunch of stuff...
File "/usr/lib/python2.3/site-packages/zope/interface/advice.py", line 132, in advise return callback(newClass) File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 550, in _implements_advice classImplements(cls, *interfaces) File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 527, in classImplements spec.declared += tuple(_normalizeargs(interfaces)) File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 1345, in _normalizeargs_normalizeargs(v, output) File "/usr/lib/python2.3/site-packages/zope/interface/declarations.py", line 1344, in _normalizeargs for v in sequence: exceptions.TypeError: iteration over non-sequence
Failed to load application: iteration over non-sequence
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
![](https://secure.gravatar.com/avatar/7ed9784cbb1ba1ef75454034b3a8e6a1.jpg?s=120&d=mm&r=g)
On Fri, 28 Jul 2006 15:42:44 -0400 (EDT), lloyd@paisite.com wrote:
Hi Valentino,
On Thu, July 27, 2006 1:38 pm, Valentino Volonghi aka Dialtone wrote:
This is right. Nevow and the new Twisted do require zope.interface to work. It's is present in all ubuntu configurations and I think also debian's.
I've loaded python2.3-zopeinterface from Debian repository and, in my devel system, have renamed ResourceMagic.py ResourceMagic.tac.
Now when I run twistd -noy ResourceMagic.tac I get the error shown below. Can't figure out how to track it down.
You really want to be running a newer Twisted than 1.3.0. There will be all sorts of compatibility problems between it, Zope Interface, and any reasonably recent version of Nevow. Generally there should be a lot of flex in the version dependencies between Twisted and Nevow, but the Zope Interface change was massive and pervasive, so things are pretty much just broken if you don't use the right versions together. Jean-Paul
![](https://secure.gravatar.com/avatar/2829e7f709de61c15d69a67c8d22109d.jpg?s=120&d=mm&r=g)
Hi, On Fri, July 28, 2006 4:37 pm, Jean-Paul Calderone wrote:
You really want to be running a newer Twisted than 1.3.0. There will be all sorts of compatibility problems between it, Zope Interface, and any reasonably recent version of Nevow.
Generally there should be a lot of flex in the version dependencies between Twisted and Nevow, but the Zope Interface change was massive and pervasive, so things are pretty much just broken if you don't use the right versions together.
Thanks, Jean-Paul. I'll give it a shot. Best wishes, Lloyd
![](https://secure.gravatar.com/avatar/2829e7f709de61c15d69a67c8d22109d.jpg?s=120&d=mm&r=g)
Hello, On Fri, July 28, 2006 4:37 pm, Jean-Paul Calderone wrote:
You really want to be running a newer Twisted than 1.3.0. There will be all sorts of compatibility problems between it, Zope Interface, and any reasonably recent version of Nevow.
And now my Turkey brain is running on empty. Help, help, help. All I want to do is get my Twisted environment back up and running so I can develop and test Turkey Adventures. But everything seems to be broken. I'm running Debian Sarge. I use Apt-Get or, more usually, Synaptic, to load applications. I've loaded the following packages: Python2.3 version: 2.3.5-3sarge1 Python2.3-nevow version: 0.3.0-1 Python2.3-twisted version: 1.3.0-8 Python2.3-zopeinterface version: 3.0.1-1 The only upgrade packages I see when I search via Synaptic are: Python2.4 version 2.4.1-2 Python2.4-zopeinterface version 3.0.1-1 There are no Python2.4 nevow or twisted upgrades. When I go to the Twisted download page, all I see are tarballs. So... Do I need to go elsewhere to find upgrade files for Debian; e.g. deb packages? Or, do I need to use some other method such as tarballs to upgrade (if so, I'll need a LOT of guidance to put everything in the right place and properly configure it.)? Or, am I missing something else entirely? Once again I seem to bitten by the problem of doc writers assuming that turkeys like me know more than we do. Many thanks, Lloyd
![](https://secure.gravatar.com/avatar/10aa56aec887e973085025c6ddfdc46b.jpg?s=120&d=mm&r=g)
On Sat, 29 Jul 2006 11:44:10 -0400 (EDT), lloyd@paisite.com wrote:
I'm running Debian Sarge. I use Apt-Get or, more usually, Synaptic, to load applications. I've loaded the following packages:
Python2.3 version: 2.3.5-3sarge1 Python2.3-nevow version: 0.3.0-1 Python2.3-twisted version: 1.3.0-8 Python2.3-zopeinterface version: 3.0.1-1
The only upgrade packages I see when I search via Synaptic are:
Python2.4 version 2.4.1-2 Python2.4-zopeinterface version 3.0.1-1
There are no Python2.4 nevow or twisted upgrades.
When I go to the Twisted download page, all I see are tarballs.
So...
Do I need to go elsewhere to find upgrade files for Debian; e.g. deb packages?
Or, do I need to use some other method such as tarballs to upgrade (if so, I'll need a LOT of guidance to put everything in the right place and properly configure it.)?
Or, am I missing something else entirely?
Once again I seem to bitten by the problem of doc writers assuming that turkeys like me know more than we do.
If you have subversion installed you can do the following: - Install ZopeInterface 3.1: $ wget http://www.zope.org/Products/ZopeInterface/3.1.0c1/ZopeInterface-3.1.0c1.tgz $ tar xzvf ZopeInterface-3.1.0c1.tgz $ cd ZopeInterface-3.1.0c1 $ python setup.py install - Install Divmod (Which includes Combinator, Axiom, Mantissa, Epsilon, Nevow, Quotient and many others): $ cd /usr/src/ $ mkdir Divmod $ cd Divmod $ svn co http://divmod.org/svn/Divmod/trunk - Setup Combinator: $ echo "`python /usr/src/Divmod/trunk/Combinator/envirnment.py`" >> ~/.bashrc $ source ~/.bashrc - Activate trunk branch for Divmod repository: $ cd /usr/src/ $ chbranch Divmod trunk - Activate trunk branch for Twisted repository $ chbranch Twisted trunk svn://svn.twistedmatrix.com/svn/Twisted/trunk Reboot your shell
From now on thanks (or not) to Combinator you'll install libraries in ~/.local/ it's possible to change this although I'm unsure you really want to, IMHO there should be a env var setting that allows for changing this directory, anyway this is not very important for this small installation tutorial.
This is the best setup for working with nevow and twisted and divmod. Updating any of the above packets only requires an svn up in the corresponding directory (Divmod/trunk for Nevow and Divmod related software, Twisted/trunk for Twisted Matrix). In this tutorial /usr/src/ is considered the projects directory. As for Debian Sarge... Well that's not really the best system for application development in Twisted since it only contains pretty old versions (for good or for bad reasons). Probably Debian unstable has the latest versions of all those but the best choice for a developer of Twisted is Ubuntu Dapper currently. Of course there's nothing you cannot do in a Debian system that you can do in an Ubuntu system, it's simply a matter of having to do more manual work rather than relying to apt (for example in my projects I use lighttpd and my current hosting provides me only with Ubuntu 5.10 which doesn't have lighttpd packaged and I had to compile it manually, not too bad if you know how to do it but not as comfortable as with Ubuntu Dapper).
![](https://secure.gravatar.com/avatar/2829e7f709de61c15d69a67c8d22109d.jpg?s=120&d=mm&r=g)
Hi, On Sat, July 29, 2006 12:13 pm, Valentino Volonghi aka Dialtone wrote:
- Install ZopeInterface 3.1: $ wget http://www.zope.org/Products/ZopeInterface/3.1.0c1/ZopeInterface-3.1.0c1. tgz $ tar xzvf ZopeInterface-3.1.0c1.tgz $ cd ZopeInterface-3.1.0c1 $ python setup.py install
At this step I got the following error: Cube1:~/ZopeInterface-3.1.0c1# python setup.py install running install error: invalid Python installation: unable to open /usr/lib/python2.3/config/Makefile (No such file or directory) I reinstalled Python2.3 to see if that would make a difference, but it didn't. Thanks, Lloyd
![](https://secure.gravatar.com/avatar/f9a435166977fabd5d9fdf4bba5d5459.jpg?s=120&d=mm&r=g)
Hi Lloyd, On Mon, 31 Jul 2006 17:49:00 -0500, <lloyd@paisite.com> wrote:
Hi,
On Sat, July 29, 2006 12:13 pm, Valentino Volonghi aka Dialtone wrote:
- Install ZopeInterface 3.1: $ wget http://www.zope.org/Products/ZopeInterface/3.1.0c1/ZopeInterface-3.1.0c1. tgz $ tar xzvf ZopeInterface-3.1.0c1.tgz $ cd ZopeInterface-3.1.0c1 $ python setup.py install
At this step I got the following error:
Cube1:~/ZopeInterface-3.1.0c1# python setup.py install running install error: invalid Python installation: unable to open /usr/lib/python2.3/config/Makefile (No such file or directory)
I reinstalled Python2.3 to see if that would make a difference, but it didn't.
I'm betting you need some kind of python-dev package. I'm no Linux person, but I do believe that many distributions split python into two packages, one with the basic python install, and the other with dev tool, libs, etc. Hope this helps, L. Daniel Burr
![](https://secure.gravatar.com/avatar/2829e7f709de61c15d69a67c8d22109d.jpg?s=120&d=mm&r=g)
Hi, On Mon, July 31, 2006 7:36 pm, L. Daniel Burr wrote: Thanks, Daniel. Definite progress. Did require Python2.3-dev package. But now... I get to the following step: - Install ZopeInterface 3.1: $ wget http://www.zope.org/Products/ZopeInterface/3.1.0c1/ZopeInterface-3.1.0c1.tgz $ tar xzvf ZopeInterface-3.1.0c1.tgz $ cd ZopeInterface-3.1.0c1 $ python setup.py install - Install Divmod (Which includes Combinator, Axiom, Mantissa, Epsilon, Nevow, Quotient and many others): $ cd /usr/src/ $ mkdir Divmod $ cd Divmod $ svn co http://divmod.org/svn/Divmod/trunk - Setup Combinator: $ echo "`python /usr/src/Divmod/trunk/Combinator/envirnment.py`" >> ~/.bashrc And I get this error: File "/usr/src/Divmod/trunk/Combinator/combinator/branchmgr.py", line 129, in getCurrentBranches for yth in os.listdir(self.sitePathsPath): OSError: [Errno 2] No such file or directory: '/usr/src/combinator_paths' Please advise. Thanks again, Lloyd
![](https://secure.gravatar.com/avatar/10aa56aec887e973085025c6ddfdc46b.jpg?s=120&d=mm&r=g)
On Mon, 31 Jul 2006 21:07:26 -0400 (EDT), lloyd@paisite.com wrote:
- Setup Combinator: $ echo "`python /usr/src/Divmod/trunk/Combinator/envirnment.py`" >> ~/.bashrc
And I get this error:
File "/usr/src/Divmod/trunk/Combinator/combinator/branchmgr.py", line 129, in getCurrentBranches for yth in os.listdir(self.sitePathsPath): OSError: [Errno 2] No such file or directory: '/usr/src/combinator_paths'
Please advise.
You probably don't have enough permissions to create that directory, you can create it manually and restart the shell to see what happens.
participants (4)
-
Jean-Paul Calderone
-
L. Daniel Burr
-
lloyd@paisite.com
-
Valentino Volonghi aka Dialtone