1 # vim: set et sw=4 sts=4 encoding=utf-8 :
3 __all__ = ('validate_get', 'validate_set', 'validate_new')
5 from turbogears import redirect
6 from cherrypy import NotFound
8 def validate_get(cls, name, id, url='../list'):
10 return cls.get(int(id))
11 except (ValueError, LookupError):
14 def validate_set(cls, name, id, data, url='../edit'):
15 r = validate_get(cls, name, id)
19 raise redirect('%s/%s' % (url, id), tg_flash=_(u'No se pudo ' \
20 'modificar el %s (error: %s).') % (name, e), **data)
22 def validate_new(cls, name, data, url='new'):
26 raise redirect(url, tg_flash=_(u'No se pudo crear el nuevo %s ' \
27 '(error: %s).') % (name, e), **data)