~maddevelopers/mg5amcnlo/WWW5_caching

« back to all changes in this revision

Viewing changes to madgraph3/controllers/secure.py

  • Committer: John Doe
  • Date: 2013-03-25 20:27:02 UTC
  • Revision ID: john.doe@gmail.com-20130325202702-5sk3t1r8h33ca4p4
first clean version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
6
 
 
7
from madgraph3.lib.base import BaseController
 
8
 
 
9
__all__ = ['SecureController']
 
10
 
 
11
class SecureController(BaseController):
 
12
    """Sample controller-wide authorization"""
 
13
    
 
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'))
 
17
    
 
18
    @expose('madgraph3.templates.index')
 
19
    def index(self):
 
20
        """Let the user know that's visiting a protected controller."""
 
21
        flash(_("Secure Controller here"))
 
22
        return dict(page='index')
 
23
    
 
24
    @expose('madgraph3.templates.index')
 
25
    def some_where(self):
 
26
        """Let the user know that this action is protected too."""
 
27
        return dict(page='some_where')