1
# -*- coding: utf-8 -*-
2
"""Sample controller with all its actions protected."""
3
from tg import expose, flash
4
from tg.i18n import ugettext as _, lazy_ugettext as l_
5
from tg.predicates import has_permission
7
from madgraph3.lib.base import BaseController
9
__all__ = ['SecureController']
11
class SecureController(BaseController):
12
"""Sample controller-wide authorization"""
14
# The predicate that must be met for all the actions in this controller:
15
allow_only = has_permission('manage',
16
msg=l_('Only for people with the "manage" permission'))
18
@expose('madgraph3.templates.index')
20
"""Let the user know that's visiting a protected controller."""
21
flash(_("Secure Controller here"))
22
return dict(page='index')
24
@expose('madgraph3.templates.index')
26
"""Let the user know that this action is protected too."""
27
return dict(page='some_where')