Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
plone.protect.utils.protect Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes

 checkers

Detailed Description

Definition at line 8 of file utils.py.


Constructor & Destructor Documentation

def plone.protect.utils.protect.__init__ (   self,
  checkers 
)

Definition at line 9 of file utils.py.

00009 
00010     def __init__(self, *checkers):
00011         self.checkers = checkers

Here is the caller graph for this function:


Member Function Documentation

def plone.protect.utils.protect.__call__ (   self,
  callable 
)

Definition at line 12 of file utils.py.

00012 
00013     def __call__(self, callable):
00014         spec = inspect.getargspec(callable)
00015         args, defaults = spec[0], spec[3]
00016         try:
00017             r_index = args.index("REQUEST")
00018         except ValueError:
00019             raise ValueError("No REQUEST parameter in callable signature")
00020 
00021         arglen = len(args)
00022         if defaults is not None:
00023             defaults = zip(args[arglen - len(defaults):], defaults)
00024             arglen -= len(defaults)
00025 
00026         def _curried(*args, **kw):
00027             request = None
00028 
00029             if len(args) > r_index:
00030                 request = args[r_index]
00031 
00032             for checker in self.checkers:
00033                 checker(request)
00034 
00035             # Reconstruct keyword arguments
00036             if defaults is not None:
00037                 args, kwparams = args[:arglen], args[arglen:]
00038                 for positional, (key, default) in zip(kwparams, defaults):
00039                     if positional is _default:
00040                         kw[key] = default
00041                     else:
00042                         kw[key] = positional
00043 
00044             return callable(*args, **kw)
00045 
00046         # Build a facade, with a reference to our locally-scoped _curried
00047         facade_globs = dict(_curried=_curried, _default=_default)
00048         try:
00049             name = callable.__name__
00050             exec _buildFacade(name, spec, callable.__doc__) in facade_globs
00051         except TypeError: # BBB: Zope 2.10
00052             name = '_facade'
00053             exec _buildFacade(spec, callable.__doc__) in facade_globs
00054         return facade_globs[name]
00055 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 10 of file utils.py.


The documentation for this class was generated from the following file: