def validate( table, **data ):
if table not in good.keys():<EOL><INDENT>raise Proauth2Error( '<STR_LIT>', '<STR_LIT>' % table )<EOL><DEDENT>for req in good[table]['<STR_LIT>']:<EOL><INDENT>if not data.get( req, None ):<EOL><INDENT>raise Proauth2Error( '<STR_LIT>',<EOL>'<STR_LIT>' % req )<EOL><DEDENT><DEDENT>for key in data.keys():<EOL><INDENT>if key not in good[table]['<STR_LIT>'] andkey not in good[table]['<STR_LIT>']:<EOL><INDENT>raise Proauth2Error( '<STR_LIT>', '<STR_LIT>' % key )<EOL><DEDENT><DEDENT>return good[table]['<STR_LIT:key>']<EOL>
theoretically, any data store can be implemented to work with this package,
which means basic data validation must be done in-package, so that weird
stuff can't be stored in the data store.
this function raises an exception if an invalid table name is passed, not
all of the required fields are in the data kwargs, or if a field that was
passed is not expected.
it also returns the key field name, for ensuring uniqueness (again, that may
not be built into whatever data store is impelemented.)