diff -r 31114e40178d -r 0a5eb5aac0be iro/model/decorators.py --- a/iro/model/decorators.py Thu Mar 29 13:46:37 2012 +0200 +++ b/iro/model/decorators.py Thu Mar 29 16:27:40 2012 +0200 @@ -1,5 +1,11 @@ +"""All decorators, that are created by this package. + +Imports: + +- :func:`.user.vUser` -- a validator for apikeys. +- :func:`.pool.runInDBPool` -- runs a actual function in dbpool. +""" import types -from decorator import decorator from .user import vUser from .schema import Offer @@ -10,6 +16,17 @@ @dbdefer def vRoute(session, value, field, typ, allowString=True, allowList=True): + """ a validator to test a valid route. use with :func:`iro.validate.validate`. + + :param session: a valid session object (is created by decorator :func:`iro.model.dbdefer.dbdefer`) + :param value: the value to test + :param string field: the field that is tested (only used to get a propper error message). + :param string typ: a typ to test the route in + :param boolean allowString: a single route is allowd. + :param boolean allowList: a list of routes is allowed. + :return: *value*, if value is a valid route for a given typ. + :raises: :exc:`iro.error.ValidateException` + """ str_ = False ret = [] @@ -34,6 +51,15 @@ @dbdefer def vTyp(value,field, session): + """ a validator to test a valid typ. use with :func:`iro.validate.validate`. + + :param session: a valid session object (is created by decorator :func:`iro.model.dbdefer.dbdefer`) + :param value: the value to test + :param string field: the field that is tested (only used to get a propper error message). + :return: *value*, if value is a valid typ. + :raises: :exc:`iro.error.ValidateException` + """ + for typ in Offer.typs(session): if value == typ[0]: break