X-Git-Url: https://git.llucax.com/software/sercom.git/blobdiff_plain/59972c6fd03ea093bd26eca762a7f4fa5a1320dd..04677c432f0c579e2ef79e80c1c14d7f1d33369a:/sercom/subcontrollers/validate.py?ds=sidebyside diff --git a/sercom/subcontrollers/validate.py b/sercom/subcontrollers/validate.py index 67b749a..1495a9a 100644 --- a/sercom/subcontrollers/validate.py +++ b/sercom/subcontrollers/validate.py @@ -3,17 +3,13 @@ __all__ = ('validate_get', 'validate_set', 'validate_new') from turbogears import redirect +from cherrypy import NotFound def validate_get(cls, name, id, url='../list'): try: - id = int(id) - except ValueError: - raise redirect(url, tg_flash=_(u'Identificador inválido: %s.') % id) - try: - return cls.get(id) - except LookupError: - raise redirect(url, tg_flash=_(u'No existe %s con identificador %d') - % (name, id)) + return cls.get(int(id)) + except (ValueError, LookupError): + raise NotFound def validate_set(cls, name, id, data, url='../edit'): r = validate_get(cls, name, id)