On 26 March 2003, Amar Singh said:
> sorry for the html mail last time...i didnt mean to
> here's a repost of my message
>
> im new to quixote and web scripting in general. I have made a command line
> application with python that allows collections of source files to be
> searched for identifiers, function calls, class definitions etc. for
> various languages. I have also made a web front end for this application
> using quixote. I have one problem though. My application is installed as
> a package in the site-packages directory under Lib in the python install
> location, much like the quixote demo is. My application uses a metakit
> database file to store indexes and other info. The database is also stored
> in the same package as the rest of the modules. My problem is that the
> database file has to be copied to my cgi-bin directory for the searches to
> be done from the web (otherwise it is not found).
With a real operating system, you could use a symlink. But I can tell
from your #! line that you're not using a real operating system. ;->
Putting changeable data files in the Python library directory is not a
good idea if you plan to use your app on multi-user systems or
distribute it to other people. But if this is just a personal hack for
your use only (or use only on your web server), then you could do two
things:
* put the database in a "neutral" location (ie. outside of Python's
lib) and hardcode that location in your scripts
* keep the database in Python's lib, and ask Python where your module
(package?) lives:
pkg_dir = os.path.dirname(sys.modules['sscae'].__filename__)
db_file = os.path.join(pkg_dir, "mydatabase")
Hope this helps --
Greg
--
Greg Ward http://www.gerg.ca/
If ignorance is bliss, why aren't there more happy people?