Ian Bicking <[EMAIL PROTECTED]> writes:

> > I'm able to solve it by using a variable that basically checks if
> > there's been any requests yet - if not, it sets up my database
> > connection after checking the path. However, I don't like this
> > solution.
> 
> You might try using the magic __file__ attribute.  It should give the
> filename of the module.

Hmm.. 

Aha! 

When running in Appserver, os.getcwd() actually solves my problem,
since the Appserver is run from the directory where my Config
directory resides. This solution doesn't work when run with
OneShot.cgi, since the CGI have another working directory
/usr/lib/cgi-bin or wherever the web server thinks is a good location.

Using some os.path functions, I managed to get a piece of code that
returns the correct value in both situations:

--snip--
import os

p = os.path.abspath(__file__)
wdpath = os.path.normpath(p[:p.rindex('/')+1]+ '..')
--snap--

This could be a handy utilityfunction to put somewhere in Webware.

\EF
-- 
Erik Forsberg                 http://www.lysator.liu.se/~forsberg/
GPG/PGP Key: 1024D/0BAC89D9


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to