Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes
DCWorkflow.Guard.Guard Class Reference
Inheritance diagram for DCWorkflow.Guard.Guard:
Inheritance graph
[legend]
Collaboration diagram for DCWorkflow.Guard.Guard:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def check
def getSummary
def changeFromProperties
def getPermissionsText
def getRolesText
def getGroupsText
def getExprText

Public Attributes

 permissions
 roles
 groups

Static Public Attributes

tuple permissions = ()
tuple roles = ()
tuple groups = ()
 expr = None
tuple security = ClassSecurityInfo()
tuple guardForm = DTMLFile('guard', _dtmldir)

Detailed Description

Definition at line 36 of file Guard.py.


Member Function Documentation

def DCWorkflow.Guard.Guard.changeFromProperties (   self,
  props 
)
Returns 1 if changes were specified.

Definition at line 119 of file Guard.py.

00119 
00120     def changeFromProperties(self, props):
00121         '''
00122         Returns 1 if changes were specified.
00123         '''
00124         if props is None:
00125             return 0
00126         res = 0
00127         s = props.get('guard_permissions', None)
00128         if s:
00129             res = 1
00130             p = [ permission.strip() for permission in s.split(';') ]
00131             self.permissions = tuple(p)
00132         s = props.get('guard_roles', None)
00133         if s:
00134             res = 1
00135             r = [ role.strip() for role in s.split(';') ]
00136             self.roles = tuple(r)
00137         s = props.get('guard_groups', None)
00138         if s:
00139             res = 1
00140             g = [ group.strip() for group in s.split(';') ]
00141             self.groups = tuple(g)
00142         s = props.get('guard_expr', None)
00143         if s:
00144             res = 1
00145             self.expr = Expression(s)
00146         return res

def DCWorkflow.Guard.Guard.check (   self,
  sm,
  wf_def,
  ob,
  kw 
)
Checks conditions in this guard.

Definition at line 47 of file Guard.py.

00047 
00048     def check(self, sm, wf_def, ob, **kw):
00049         """Checks conditions in this guard.
00050         """
00051         u_roles = None
00052         if wf_def.manager_bypass:
00053             # Possibly bypass.
00054             u_roles = sm.getUser().getRolesInContext(ob)
00055             if 'Manager' in u_roles:
00056                 return 1
00057         if self.permissions:
00058             for p in self.permissions:
00059                 if _checkPermission(p, ob):
00060                     break
00061             else:
00062                 return 0
00063         if self.roles:
00064             # Require at least one of the given roles.
00065             if u_roles is None:
00066                 u_roles = sm.getUser().getRolesInContext(ob)
00067             for role in self.roles:
00068                 if role in u_roles:
00069                     break
00070             else:
00071                 return 0
00072         if self.groups:
00073             # Require at least one of the specified groups.
00074             u = sm.getUser()
00075             b = aq_base( u )
00076             if hasattr( b, 'getGroupsInContext' ):
00077                 u_groups = u.getGroupsInContext( ob )
00078             elif hasattr( b, 'getGroups' ):
00079                 u_groups = u.getGroups()
00080             else:
00081                 u_groups = ()
00082             for group in self.groups:
00083                 if group in u_groups:
00084                     break
00085             else:
00086                 return 0
00087         expr = self.expr
00088         if expr is not None:
00089             econtext = createExprContext(
00090                 StateChangeInfo(ob, wf_def, kwargs=kw))
00091             res = expr(econtext)
00092             if not res:
00093                 return 0
00094         return 1

Here is the call graph for this function:

Definition at line 166 of file Guard.py.

00166 
00167     def getExprText(self):
00168         if not self.expr:
00169             return ''
00170         return str(self.expr.text)
00171 
00172 InitializeClass(Guard)
00173 

Definition at line 160 of file Guard.py.

00160 
00161     def getGroupsText(self):
00162         if not self.groups:
00163             return ''
00164         return '; '.join(self.groups)

Definition at line 148 of file Guard.py.

00148 
00149     def getPermissionsText(self):
00150         if not self.permissions:
00151             return ''
00152         return '; '.join(self.permissions)

Definition at line 154 of file Guard.py.

00154 
00155     def getRolesText(self):
00156         if not self.roles:
00157             return ''
00158         return '; '.join(self.roles)

Definition at line 96 of file Guard.py.

00096 
00097     def getSummary(self):
00098         # Perhaps ought to be in DTML.
00099         res = []
00100         if self.permissions:
00101             res.append('Requires permission:')
00102             res.append(formatNameUnion(self.permissions))
00103         if self.roles:
00104             if res:
00105                 res.append('<br/>')
00106             res.append('Requires role:')
00107             res.append(formatNameUnion(self.roles))
00108         if self.groups:
00109             if res:
00110                 res.append('<br/>')
00111             res.append('Requires group:')
00112             res.append(formatNameUnion(self.groups))
00113         if self.expr is not None:
00114             if res:
00115                 res.append('<br/>')
00116             res.append('Requires expr:')
00117             res.append('<code>' + escape(self.expr.text) + '</code>')
00118         return ' '.join(res)

Here is the call graph for this function:


Member Data Documentation

DCWorkflow.Guard.Guard.expr = None [static]

Definition at line 40 of file Guard.py.

tuple DCWorkflow.Guard.Guard.groups = () [static]

Definition at line 39 of file Guard.py.

Definition at line 140 of file Guard.py.

tuple DCWorkflow.Guard.Guard.guardForm = DTMLFile('guard', _dtmldir) [static]

Definition at line 45 of file Guard.py.

Definition at line 37 of file Guard.py.

Definition at line 130 of file Guard.py.

tuple DCWorkflow.Guard.Guard.roles = () [static]

Definition at line 38 of file Guard.py.

Definition at line 135 of file Guard.py.

tuple DCWorkflow.Guard.Guard.security = ClassSecurityInfo() [static]

Definition at line 42 of file Guard.py.


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