1 # vim: set et sw=4 sts=4 encoding=utf-8 :
3 __all__ = ('validate_get', 'validate_set', 'validate_new')
5 from turbogears import redirect, flash
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 flash(_(u'No se pudo modificar el %s (error: %s).') % (name, e))
20 raise redirect('%s/%s' % (url, id), **data)
22 def validate_new(cls, name, data, url='new'):
26 flash(_(u'No se pudo crear el nuevo %s (error: %s).') % (name, e))
27 raise redirect(url, **data)