Jim Steil schrieb:
> My question is how can I find
> the top level directory of my TG app when I'm running this program.
>
> How do others handle this type of situation?
I see two possibilities:
a) Use the turbogears config module:
1) Parse your TG application's config file:
import turbogears
turbogears.update_config(configfile='/path/to/config/file.cfg',
modulename="mypackage.config")
2) Find out the path that corresponds to the "/static" URL:
self.img_dir = os.path.join(
turbogears.config.get('static_filter.dir', path="/static"), 'images')
b) Use the "pkg_resources" module from the setuptools package to find the
"static" subdirectory of your TG app's package dir:
import pkg_resources
static_dir = pkg_resources.resource_filename("mypackage", "static")
img_dir = os.path.join(static_dir, 'images')
Beware that both methods will fail, if you installed your TG app as a zipped
EGG.
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---