[Twisted-web] nevow tutorial

Luc Saffre luc.saffre at gmx.net
Wed Nov 24 21:03:42 MST 2004


On 22.11.2004 17:46, Donovan Preston wrote:

> I'm glad you like the tutorial, but the reason it isn't linked is 
> because it is out of date. It was written circa 0.1, and shows some 
> techniques which were workarounds for lack of functionality which is now 
> present in 0.3. Thus, I think it is more confusing than it should be. 

"You see how important it is to have a date on *each* document?  It's 
frustrating to see how much they neglect this old rule in Internet."
   -- my father (71 years, former director of a technical library)

>> OTOH I have a problem: the examples don't work, appearently for a 
>> silly reason. When I start "twistd -ny EXAMPLE.tac" for any of them, I 
>> get an ImportError for those modules which are in the same directory 
>> (iCal, schedule,...).
>>
>> If I start a Python shell, I can manually import these modules. It 
>> looks as if twistd removes "." from PYTHON_PATH, or chdirs to some 
>> other directory.
>>
>> This happens on my machine with Python 2.3.4 and Twisted 1.2.0 on Win32
> 
> This is a bug (or feature) of twisted on windows. Basically, twistd, as 
> a security precaution, removes '.' from your pythonpath if you are 
> running as root. On unix, you usually don't run as root if you are 
> testing (and would never deploy a configuration with needed modules 
> located in '.'). On windows, the distinction is much fuzzier. I assume 
> twistd removes '.' because you ARE running as "root" on windows.
> 
> The simple solution is to simply put the appropriate directory on your 
> PYTHONPATH before running an example. This way, you always know 
> explicitly which module you are getting, too.

That's correct, thanks for these exmplanations.

It seems to me that twistd 1.3 (on windows) doesn't remove "." from 
PYTHONPATH anymore. At least I could not reproduce my problem with 
1.3.0. So for me it now works with just a "." in PYTHONPATH.

> Also, please at least get Twisted 1.3.0. It's been out for quite a while 
> now.

Done.

 > If
 > you would be willing to attempt to work through the tutorial and ask
 > questions when things don't work or seem to be out of date, and perhaps
 > update it using the answers provided, I could cut a new version of it
 > and include it in 0.4, prominently linked on the website.

The interesting thing is the set of running examples. Most important is 
(1) that they are running, and (2) that they don't use a completely 
obsolete technique. For (1) I'll try to help.


I am trying to get example4\schedule.py running:

line 8:
-from nevow import rend
+from nevow import rend, loaders

line 13:
-    docFactory = rend.htmlfile('Month.html')
+    docFactory = loaders.htmlfile('Month.html')


... and wow! (an exciting moment when you are discovering something...):
The first page displays!

Next problem: in day.py are two imports who fail:

   from nevow import formless
   from nevow import freeform

Maybe now it's better that I wait for help or comments...

Luc



More information about the Twisted-web mailing list