On Mon, Sep 28, 2015 at 8:28 PM, Dmitry Komarov <d9k...@gmail.com> wrote:
> I want kind of #ifdef in my web service code, condition which checks if this
> code runs in production or in development mode at the time of check.
> What's the best and simpliest way?

I'm using settings like 'appname.devel', 'appname.devel.foo' to enable
development-only views and the like.

> How can I get config name from `pserve config_name.ini` command in my view
> code?

request.registry.settings["__file__"]     # Absolute path of config file.
request.registry.settings["here"]   # Directory containing config file.

However, I'd avoid assuming too much about the filename, whether it
implies development mode or not. Because it may guess wrong sometime.
They may be named the developer's initials, or a server name, or a
name like 'beta', etc.

-- 
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