If you mean "what is the best practise to convert bools", PasteDeploy
provide a few helpers:

from paste.deploy.converters import asbool

I also have this in helpers.py (don't know why I can't find something
similar in the paste namespace):

class Params(dict):
    def __getattr__(self, attr):
        return self[attr]
    def __setattr__(self, attr, value):
        self[attr] = value

def params_from_config(key):
    params = Params()
    for k, v in config['app_conf'].items():
        if k.startswith(key):
            params[k.replace(key, '')] = v
    return params

You can set all keys found to asbool(v) and change the __getattr__ to
return false by default

Then you can do:

params = h.params_from_config('org.pensn.pylons.')

and check if the feature is available: if params.enable_feature_x:

On Thu, Jan 22, 2009 at 1:30 AM, Jonathan Vanasco <[email protected]> wrote:
>
> i store a lot of stuff in config, much of which is 'framework' related
> across modules.
>
> the current way i deal with bools is this ( by storing things in
> app_globals during init )
>
>        g.enable_feature_x= False
>        if 'org.opensn.pylons.enable_feature_x' in config:
>            g.opensn_pylons.enable_feature_x = bool(int(config
> ['org.opensn.pylons.enable_feature_x']))
>
> is there a better way ?
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to