If you don't want to deal with examining the request each time, you can 
populate the templating environment with a variable or even a 
function/package that has the tests using event subscribers.

def BeforeRender_event(event):
    request = event.get("request") or threadlocal.get_current_request()
    event["environment"] = request.registry.settings...
    event["helper_library"] = myapp.lib.helper_library


config.add_subscriber(
    "BeforeRender_event",
    "pyramid.events.BeforeRender")


fwiw, as part of my build/deploy process I symlink onto `myapp/settings.py` 
either `myapp/-settings-production.py` or '-settings-development.py`.  the 
files just contain a few boolean variables -- `PRODUCTION= True`, 
`DEVELOPMENT=False` -- and no imports.  This way I can just do :

    import myapp.settings
    if myapp.settings.PRODUCTION:
         pass

The benefit of this is that we have a super-lightweight environment check, 
and other python services/apps we run in production can easily query this 
info without importing/running pyramid.
    

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to