source: gutenbach-web/secure.py @ 973dd91

debianmacno-cupsweb
Last change on this file since 973dd91 was 973dd91, checked in by Edward Z. Yang <edwardzyang@…>, 16 years ago

Initial commit.

Signed-off-by: Edward Z. Yang <edwardzyang@…>

  • Property mode set to 100644
File size: 1.0 KB
RevLine 
[973dd91]1"""Test Secure Controller"""
2from sipbmp3web.lib.base import BaseController
3from tg import expose, flash
4from pylons.i18n import ugettext as _
5#from tg import redirect, validate
6#from sipbmp3web.model import DBSession, metadata
7#from dbsprockets.dbmechanic.frameworks.tg2 import DBMechanic
8#from dbsprockets.saprovider import SAProvider
9from repoze.what.predicates import has_permission
10
11
12class SecureController(BaseController):
13    """Sample controller-wide authorization"""
14
15    # The predicate that must be met for all the actions in this controller:
16    allow_only = has_permission('manage',
17                                msg=_('Only for people with the "manage" permission'))
18
19    @expose('sipbmp3web.templates.index')
20    def index(self):
21        flash(_("Secure Controller here"))
22        return dict(page='index')
23
24    @expose('sipbmp3web.templates.index')
25    def some_where(self):
26        """should be protected because of the require attr
27        at the controller level.
28        """
29        return dict(page='some_where')
Note: See TracBrowser for help on using the repository browser.