From: haaserd <ha...@ya...> - 2001-06-14 02:02:59
|
Thanks, that fixed the problem. On to the next one: I had to put this patch in around line 386 of the "serve" function before I could import any modules out of the directory that holds my .py scripts. if self.setting('ChangeDir'): #rdh 6/13/1 sys.path.append(os.path.split(self._scriptPathname)[0]) #end rdh origDir = os.getcwd() os.chdir(os.path.split(self._scriptPathname)[0]) It seems the point of doing the os.chdir is to allow the script being executed to import additional modules out of its own directory. This doesn't seem to work with W/me after an execfile. I posted the following under the title "os.chdir() and import" on comp.lang.python earlier today, no response yet: "Under Windows and Python 2.1, I am sometimes able to use an os.chdir('xxx') and then follow this with an import command for a module located in the 'xxx' directory. However, it seems that when the module doing the os.chdir('xxx') and import-ing is executing because of an execfile() command, this technique doesn't work and an import error occurs. A search of the documentation seems to indicate that the import search path is determined only by the value of sys.path ("...It [import] generally involves searching for a ``built-in'' module with the given name and then searching a list of locations given as sys.path." -- Python Reference Manual 6.11). I think "generally" here may refer to the unique processing used for packages, but...? Can someone clear this up for me? Should sys.path always be modified instead of using os.chdir?" Roger Haase Chuck Esterbrook wrote: > At 07:38 PM 6/12/2001 -0700, haaserd wrote: > >Hi, > > > >I am trying to get my first (old) application running under > >CGIWrapper. > > > >I am running Windows ME with Apache as a server. I have the > >5.1 Webware download. > > > >I have copied the Hello.py program from the > >/Webware/CGIWrapper/Examples directory into my application > >script directory. When I run it, it says "Hello" correctly. > > > >After modifying Hello.py by adding the line > > a = 1 + 'a' > >to make it crash, I get the following output: > > I have checked in the fix to CVS, but I haven't tested it. Could you? > > I'm pretty confident that it will work, because I was able to borrow the > function directly from WebKit where I know it works. > > Please let me know. > > CVS instructions are at: > https://sourceforge.net/cvs/?group_id=4866 > > -Chuck _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com |