Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
CMFCore.ActionInformation.ActionInfo Class Reference
Inheritance diagram for CMFCore.ActionInformation.ActionInfo:
Inheritance graph
[legend]
Collaboration diagram for CMFCore.ActionInformation.ActionInfo:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __getitem__
def __eq__
def copy

Public Attributes

 data

Private Member Functions

def _checkPermissions

Private Attributes

 _ec
 _lazy_keys
 _permissions

Static Private Attributes

 __implements__ = z2IActionInfo
int __allow_access_to_unprotected_subobjects__ = 1

Detailed Description

A lazy dictionary for Action infos.

Definition at line 159 of file ActionInformation.py.


Constructor & Destructor Documentation

def CMFCore.ActionInformation.ActionInfo.__init__ (   self,
  action,
  ec 
)

Definition at line 169 of file ActionInformation.py.

00169 
00170     def __init__(self, action, ec):
00171 
00172         if isinstance(action, dict):
00173             lazy_keys = []
00174             UserDict.__init__(self, action)
00175             if 'name' in self.data:
00176                 self.data.setdefault( 'id', self.data['name'].lower() )
00177                 self.data.setdefault( 'title', self.data['name'] )
00178                 del self.data['name']
00179             self.data.setdefault( 'url', '' )
00180             self.data.setdefault( 'category', 'object' )
00181             self.data.setdefault( 'visible', True )
00182             self.data['available'] = True
00183         else:
00184             # if action isn't a dict, it has to implement IAction
00185             (lazy_map, lazy_keys) = action.getInfoData()
00186             UserDict.__init__(self, lazy_map)
00187 
00188         self.data['allowed'] = True
00189         permissions = self.data.pop( 'permissions', () )
00190         if permissions:
00191             self.data['allowed'] = self._checkPermissions
00192             lazy_keys.append('allowed')
00193 
00194         self._ec = ec
00195         self._lazy_keys = lazy_keys
00196         self._permissions = permissions

Here is the call graph for this function:


Member Function Documentation

def CMFCore.ActionInformation.ActionInfo.__eq__ (   self,
  other 
)

Definition at line 204 of file ActionInformation.py.

00204 
00205     def __eq__(self, other):
00206         # this is expensive, use it with care
00207         [ self.__getitem__(key) for key in self._lazy_keys ]
00208 
00209         if isinstance(other, self.__class__):
00210             [ other[key] for key in other._lazy_keys ]
00211             return self.data == other.data
00212         elif isinstance(other, UserDict):
00213             return self.data == other.data
00214         else:
00215             return self.data == other

Here is the call graph for this function:

Definition at line 197 of file ActionInformation.py.

00197 
00198     def __getitem__(self, key):
00199         value = UserDict.__getitem__(self, key)
00200         if key in self._lazy_keys:
00201             value = self.data[key] = value(self._ec)
00202             self._lazy_keys.remove(key)
00203         return value

Here is the caller graph for this function:

def CMFCore.ActionInformation.ActionInfo._checkPermissions (   self,
  ec 
) [private]
Check permissions in the current context.

Definition at line 221 of file ActionInformation.py.

00221 
00222     def _checkPermissions(self, ec):
00223         """ Check permissions in the current context.
00224         """
00225         category = self['category']
00226         object = ec.contexts['object']
00227         if object is not None and ( category.startswith('object') or
00228                                     category.startswith('workflow') or
00229                                     category.startswith('document') ):
00230             context = object
00231         else:
00232             folder = ec.contexts['folder']
00233             if folder is not None and category.startswith('folder'):
00234                 context = folder
00235             else:
00236                 context = ec.contexts['portal']
00237 
00238         for permission in self._permissions:
00239             if _checkPermission(permission, context):
00240                 return True
00241         return False
00242 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 216 of file ActionInformation.py.

00216 
00217     def copy(self):
00218         c = UserDict.copy(self)
00219         c._lazy_keys = self._lazy_keys[:]
00220         return c


Member Data Documentation

Definition at line 167 of file ActionInformation.py.

CMFCore.ActionInformation.ActionInfo.__implements__ = z2IActionInfo [static, private]

Definition at line 165 of file ActionInformation.py.

Definition at line 193 of file ActionInformation.py.

Definition at line 194 of file ActionInformation.py.

Definition at line 195 of file ActionInformation.py.

Definition at line 210 of file ActionInformation.py.


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