Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(12)  |  Call(0)  |  Derive(0)  |  Import(12)
Create a request method specific decorator

        def requestmethod(*methods):
    """Create a request method specific decorator"""
    methods = map(lambda m: m.upper(), methods)
    if len(methods) > 1:
        methodsstr = ', '.join(methods[:-1])
        methodsstr += ' or ' + methods[-1]
    else:
        methodsstr = methods[0]

    def _methodtest(callable):
        """Only allow callable when request method is %s.""" % methodsstr
        spec = inspect.getargspec(callable)
        args, defaults = spec[0], spec[3]
        try:
            r_index = args.index('REQUEST')
        except ValueError:
            raise ValueError('No REQUEST parameter in callable signature')
        
        arglen = len(args)
        if defaults is not None:
            defaults = zip(args[arglen - len(defaults):], defaults)
            arglen -= len(defaults)
            
        def _curried(*args, **kw):
            request = args[r_index]
            if IBrowserRequest.providedBy(request):
                if request.method not in methods:
                    raise Forbidden('Request must be %s' % methodsstr)
    
            # Reconstruct keyword arguments
            if defaults is not None:
                args, kwparams = args[:arglen], args[arglen:]
                for positional, (key, default) in zip(kwparams, defaults):
                    if positional is _default:
                        kw[key] = default
                    else:
                        kw[key] = positional
                        
            return callable(*args, **kw)
        
        # Build a facade, with a reference to our locally-scoped _curried
        name = callable.__name__
        facade_globs = dict(_curried=_curried, _default=_default)
        exec _buildFacade(name, spec, callable.__doc__) in facade_globs
        return facade_globs[name]
    
    return _methodtest
        


src/z/o/Zope2-2.13.22/src/OFS/userfolder.py   Zope2(Download)
from AccessControl.class_init import InitializeClass
from AccessControl.Permissions import manage_users as ManageUsers
from AccessControl.requestmethod import requestmethod
from AccessControl.rolemanager import DEFAULTMAXLISTUSERS
from AccessControl import userfolder as accesscontrol_userfolder

src/z/o/Zope2-2.13.22/src/OFS/role.py   Zope2(Download)
from AccessControl.Permission import Permission
from AccessControl.Permissions import change_permissions
from AccessControl.requestmethod import requestmethod
 
 

src/z/o/Zope2-2.13.22/src/OFS/owner.py   Zope2(Download)
from AccessControl.Permissions import view_management_screens
from AccessControl.Permissions import take_ownership
from AccessControl.requestmethod import requestmethod
from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl.SecurityManagement import getSecurityManager

src/z/o/Zope2-2.13.22/src/OFS/DTMLMethod.py   Zope2(Download)
from AccessControl.Permissions import view as View
from AccessControl.Permissions import ftp_access
from AccessControl.requestmethod import requestmethod
from AccessControl.tainted import TaintedString
from DocumentTemplate.permissions import change_dtml_methods

src/z/o/Zope2-2.13.22/src/App/ApplicationManager.py   Zope2(Download)
 
from AccessControl.class_init import InitializeClass
from AccessControl.requestmethod import requestmethod
from AccessControl.SecurityManagement import getSecurityManager
from Acquisition import Implicit

src/z/o/Zope-HEAD/src/OFS/userfolder.py   Zope(Download)
from AccessControl.class_init import InitializeClass
from AccessControl.Permissions import manage_users as ManageUsers
from AccessControl.requestmethod import requestmethod
from AccessControl.rolemanager import DEFAULTMAXLISTUSERS
from AccessControl import userfolder as accesscontrol_userfolder

src/z/o/Zope-HEAD/src/OFS/role.py   Zope(Download)
from AccessControl.Permission import Permission
from AccessControl.Permissions import change_permissions
from AccessControl.requestmethod import requestmethod
 
 

src/z/o/Zope-HEAD/src/OFS/owner.py   Zope(Download)
from AccessControl.Permissions import view_management_screens
from AccessControl.Permissions import take_ownership
from AccessControl.requestmethod import requestmethod
from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl.SecurityManagement import getSecurityManager

src/z/o/Zope-HEAD/src/OFS/DTMLMethod.py   Zope(Download)
from AccessControl.Permissions import view as View
from AccessControl.Permissions import ftp_access
from AccessControl.requestmethod import requestmethod
from AccessControl.tainted import TaintedString
from DocumentTemplate.permissions import change_dtml_methods

src/z/o/Zope-HEAD/src/App/ApplicationManager.py   Zope(Download)
 
from AccessControl.class_init import InitializeClass
from AccessControl.requestmethod import requestmethod
from Acquisition import Implicit
from App.CacheManager import CacheManager

  1 | 2  Next