Re: Schemas with dotted variables

Ian Bicking <[email protected]> Thu, 22 Jan 2009 14:36:57 -0600
Newsgroups gmane.comp.python.formencode
Message-ID <[email protected]>
On Thu, Jan 22, 2009 at 2:24 PM, Mike Orr <[email protected]> wrote:

> FormEncode schemas seem like a good way to validate other kinds of
> data besides form input, in particular a Pylons configuration from an
> INI file.  However, the schema format does not allow variables with
> dots in their names, which is common in this situation.
>
> I wonder if a small enhancement would alleviate this, such as treating
> a double underscore in the middle of a name as a dot.
>
>    class ConfigValidator(Schema):
>        beaker__cache_time = Integer()    #  =>   {'beaker.cache_time':
> 3600}
>
> Or the schema class could have a dict attribute of validators to merge in:
>
>    class ConfigValidator(Schema):
>        other_validators = {
>            "beaker.cache_time":  Integer(),
>            }


I'm pretty sure this works:

class ConfigValidator(Schema):
    fields = {'beaker.cache_time': Integer()}


-- 
Ian Bicking  |  http://blog.ianbicking.org

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword

_______________________________________________
FormEncode-discuss mailing list
FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/formencode-discuss