Back to index

plone3  3.1.7
Functions
five.customerize.utils Namespace Reference

Functions

def isTemplate
def findViewletTemplate
def checkPermission

Function Documentation

def five.customerize.utils.checkPermission (   permission,
  context 
)

Definition at line 31 of file utils.py.

00031 
00032 def checkPermission(permission, context):
00033     sm = getSecurityManager()
00034     if permission is not None:
00035         if not sm.checkPermission(permission, context):
00036             raise Unauthorized('The current user does not have the '
00037                                'required "%s" permission' % permission)
00038 
try to find the attribute holding the template within a viewlet 

Definition at line 16 of file utils.py.

00016 
00017 def findViewletTemplate(viewlet):
00018     """ try to find the attribute holding the template within a viewlet """
00019     for attr in 'index', 'template', '_template', '__call__', 'render':
00020         item = getattr(viewlet, attr, None)
00021         if isTemplate(item):
00022             return attr, item
00023     attrs = [ attr for attr in dir(viewlet) if isTemplate(getattr(viewlet, attr, None)) ]
00024     if len(attrs) == 1:
00025         return attrs[0], getattr(viewlet, attrs[0])
00026     else:
00027         # TODO: we should pass on the message if we find multiple templates
00028         pass
00029     return None, None
00030 

Here is the call graph for this function:

Here is the caller graph for this function:

check if the given object is a or is derived from a template class 

Definition at line 8 of file utils.py.

00008 
00009 def isTemplate(obj):
00010     """ check if the given object is a or is derived from a template class """
00011     # TODO: we should really check via interfaces, i.e. `providedBy` here,
00012     #       but the only class using interfaces atm is Z3PTF :(
00013     return isinstance(obj, Z2PTF) or isinstance(obj, Z3PTF) or \
00014         isinstance(obj, BoundPageTemplate)
00015 

Here is the caller graph for this function: