From: Leandro Lucarella Date: Fri, 16 Feb 2007 00:09:23 +0000 (+0000) Subject: Reportar error de URL como 404 en vez de un redirect. X-Git-Tag: pre-merge~142 X-Git-Url: https://git.llucax.com/z.facultad/75.52/sercom.git/commitdiff_plain/b095cc64b996bdb63bbddd051887a6180770c684 Reportar error de URL como 404 en vez de un redirect. --- diff --git a/sercom/subcontrollers/docente/__init__.py b/sercom/subcontrollers/docente/__init__.py index d7d58bc..4759fa6 100644 --- a/sercom/subcontrollers/docente/__init__.py +++ b/sercom/subcontrollers/docente/__init__.py @@ -1,5 +1,6 @@ # vim: set et sw=4 sts=4 encoding=utf-8 : +import cherrypy from turbogears import controllers, expose, redirect from turbogears import validate, validators, flash, error_handler from turbogears.widgets import * @@ -70,9 +71,9 @@ class DocenteController(controllers.Controller, identity.SecureResource): r = validate_get(id) try: r.activo = bool(int(activo)) - except ValueError, e: - raise redirect('../list', tg_flash=_(u'Acción inválida.')) - raise redirect('../list') + except ValueError: + raise cherrypy.NotFound + raise redirect('../../list') @expose(template='kid:%s.templates.new' % __name__) def new(self, **kw): diff --git a/sercom/subcontrollers/docente/templates/list.kid b/sercom/subcontrollers/docente/templates/list.kid index 2ffe51c..0bcec6b 100644 --- a/sercom/subcontrollers/docente/templates/list.kid +++ b/sercom/subcontrollers/docente/templates/list.kid @@ -24,7 +24,7 @@ usuario nombre 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)