# 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 *
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):
<tr py:for="record in records">
<td><input type="checkbox" onclick="var f =
document.createElement('form'); this.parentNode.appendChild(f);
- f.method = 'POST'; f.action = '${tg.url('/docente/activate/%d' % record.id, activo=str(int(not record.activo)))}';
+ f.method = 'POST'; f.action = '${tg.url('/docente/activate/%d/%d' % (record.id, int(not record.activo)))}';
f.submit(); return false;" py:attrs="checked=tg.checker(record.activo)" /></td>
<td><a href="${tg.url('/docente/show/%d' % record.id)}"><span py:replace="record.usuario">usuario</span></a></td>
<td><span py:replace="record.nombre">nombre</span></td>
__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)