Schemas with dotted variables

Mike Orr <[email protected]> Thu, 22 Jan 2009 12:24:57 -0800
Newsgroups gmane.comp.python.formencode
Message-ID <[email protected]>
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(),
            }

-- 
Mike Orr <[email protected]>

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