> > What is the recommended way to configure my application find the various 
> database and/or configuration files it needs?
> 
> Recommemded by whom? A lot depends on the OS. Apple for example have one set 
> of 
> recommendations for MacOS, Windows has another and Linux has several to 
> choose 
> from!
> 


Thank you.... good point.

Planning on using a ConfigParser based .ini file located in the ./config folder.

> > For instance my folder layout:
> > 
> > /path_to_app/app.py
> > /path_to_app/lib/
> > /path_to_app/database/
> > /path_to_app/config/
> > /path_to_app/photos
> > 
> > .... and so on.  I would like to make an .ini in the config folder 
> 
> Seems fair enough, however on a Unix system you should also consider allowing 
> the user to have their own personalised version in their home directory. Thus 
> at 
> startup you get the current user ID / home directory and look for a suitable 
> config file. If it exists read it, if not read the default one in your config 
> directory.
>
> > 1) How does my main app file find the config file in the first place?
> 
> Generally use a relative path so normally your app will run from its home 
> folder 
> so you can look in ./config. You might also set a system environment variable 
> - 
> for example the CLASSPATH or PYTHONPATH variables, or the ORACLE_HOME used by 
> Oracle for their database. If the environment var is not set then look in 
> ./config
>

Assuming the application could be invoked in odd ways that may alter the notion 
of the current working directory, how do I unambiguously find the absolute path 
to the current python source file?  (So I can load the nearby .ini)


As a follow-up question, how do give my modules stored under ./lib access to 
the data in my ConfigParser object?  (For instance, database connection string, 
storage path, etc.)

I guess a global ConfigParser object would work, but that seems wrong.


      

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to