iro/model/decorators.py
branchdevel
changeset 118 e16c0250c974
parent 117 351a02310dd8
child 122 b55754aa4f96
equal deleted inserted replaced
117:351a02310dd8 118:e16c0250c974
    11     @decorator
    11     @decorator
    12     def wrapper(f, *args, **kwargs):
    12     def wrapper(f, *args, **kwargs):
    13         return f(*args, **kwargs)
    13         return f(*args, **kwargs)
    14     return wrapper
    14     return wrapper
    15 
    15 
    16 from .utils import WithSession
    16 @dbdefer
    17 #@dbdefer
    17 def vTyp(value,field, session):
    18 def vTyp(value,field):
    18     for typ in session.query(Offer.typ).distinct():
    19     with WithSession(dbdefer.engine) as session:
    19         if value == typ[0]:
    20         for typ in session.query(Offer.typ).distinct():
    20             break
    21             if value == typ[0]:
    21     else:
    22                 break
    22         raise ValidateException(field=field,msg='Typ is not valid.')
    23         else:
       
    24             raise ValidateException(field=field,msg='Typ is not valid.')
       
    25     return value
    23     return value