Re: [Twisted-Python] Question regarding widgets
---------- Original Message ----------------------------------
From: Andrew Bennetts
On Wed, Nov 06, 2002 at 09:00:13AM +0800, lals;dfjsd wrote:
IIRC. However, I don't understand what you're trying to do here. If you have Twisted installed in your C:\python22\lib\site-packages (as with setup.py or the .exe installer) then you shouldn't be adding anything to your PYTHONPATH to get 'twisted' to import.
Well following the example for woven, I thought that you needed to add to pythonpath where ever you are putting your code for your application, as in if I want to put my code in c:\web2\mohan_koteh\ then i should add this to the pythonpath to get it to work. Isn't it so ? I just kept on trying the woven examples but without success until i added the directory which i was working on to the pythonpath. Maybe I am doing something wrong here but can someone actually tell me how it is done ?
He's just pointing out that you shouldn't need to do anything special to get Twisted itself to import -- the installer/setup.py should've done that for you (anything in %PYTHONHOME%/Lib/site-packages is automatically on the python path).
What you need to do with your own application that uses Twisted is a different question.
-Andrew.
Ummm so does that mean I have to add something to the pythonpath for a web application that I am building in a particular directory ?
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
_____________________________________________________________________ iRepublics.com - Free Web Hosting for Businesses 33MB webspace free, SMS messaging, 30 email accounts, your own domain name Sign up Now at http://www.iRepublics.com
On Wed, Nov 06, 2002 at 09:12:52AM +0800, lals;dfjsd wrote:
Ummm so does that mean I have to add something to the pythonpath for a web application that I am building in a particular directory ?
Unfortunately, I don't know -- I'm not a Twisted Web expert. :( Someone else will have to answer this one. -Andrew.
At 09:12 AM 11/6/2002 +0800, lals;dfjsd wrote:
Ummm so does that mean I have to add something to the pythonpath for a web application that I am building in a particular directory ?
I think I know what Mr. Dfjsd is getting at; I hit this same problem. If you're building an app in c:\webapp, and you run twistd from that directory, then 'c:\webapp' should be part of sys.path. The reason for this is that '.' is part of sys.path, and if you're running twistd in c:\webapp, then '.' == 'c:\webapp'. So, if: c:\webapp\docroot contains your HTML files and RPY files c:\webapp\my_app contains any Python code you need to import ...and you run: c:\webapp> mktap web --path docroot c:\webapp> twistd -f web.tap ...if you have a .rpy in c:\webapp\docroot, it can call 'import my_app' and it should work fine. (Provided c:\webapp\my_app\__init__.py exists.) Does that answer your question? (All twisted.web.woven gurus: feel free to comment or correct me. :) -- Alex Levy WWW: http://mesozoic.geecs.org Tel: 617.835.0778 "Never let your sense of morals prevent you from doing what is right." -- Salvor Hardin, Isaac Asimov's _Foundation_
On Tue, 05 Nov 2002, Alex
If you're building an app in c:\webapp, and you run twistd from that directory, then 'c:\webapp' should be part of sys.path. The reason for this is that '.' is part of sys.path, and if you're running twistd in c:\webapp, then '.' == 'c:\webapp'.
That's not correct, "." is never on your path (that'd be a serious security whole). The directory in which the script you run is on your path.
Moshe Zadka wrote:
On Tue, 05 Nov 2002, Alex
wrote: If you're building an app in c:\webapp, and you run twistd from that directory, then 'c:\webapp' should be part of sys.path. The reason for this is that '.' is part of sys.path, and if you're running twistd in c:\webapp, then '.' == 'c:\webapp'.
That's not correct, "." is never on your path (that'd be a serious security whole). The directory in which the script you run is on your path.
How is having "." on your PYTHONPATH a serious security hole? (Of course it shouldn't be on _root_'s PYTHONPATH, but how is it bad for a regular user?) -- Steve.
On Wed, 06 Nov 2002, Steve Waterbury
How is having "." on your PYTHONPATH a serious security hole? (Of course it shouldn't be on _root_'s PYTHONPATH, but how is it bad for a regular user?)
What if you run a Python program from /tmp? One of those smart programs which do something like ''' try: import gtk except ImportError: gtk = None ''' What if some malicious user put a gtk.py in /tmp which does something like ''' open(os.path.expanduser("~/.secret")) os.chmod(os.path.expanduser("~/.secret"), 0777) ''' And to top it all, assume gtk is, indeed, not installed on this system.
Moshe Zadka wrote:
On Wed, 06 Nov 2002, Steve Waterbury
wrote: How is having "." on your PYTHONPATH a serious security hole? (Of course it shouldn't be on _root_'s PYTHONPATH, but how is it bad for a regular user?)
What if you run a Python program from /tmp? ... [etc.]
Perhaps I am protected by a higher level of general paranoia: I would never run anything from /tmp (or any other directory where just anyone could write something into, but especially not from /tmp!). I only run Python scripts either from inside my home dir (for which I leave the RH default perms, drwx------) or from a root-writable-only dir such as /usr/local/... (if somebody's hacked root, I've got bigger problems anyway!). Of course, the conversation started with Windows, and I have no idea what the implications are there ... probably much more dire, like everything else on Windows. ;^) Cheers, -- Steve.
participants (5)
-
Alex
-
Andrew Bennetts
-
lals;dfjsd
-
Moshe Zadka
-
Steve Waterbury