Back to index

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

List of all members.

Static Public Attributes

string name = 'actions'

Private Member Functions

def _exportNode
def _importNode
def _extractProviders
def _extractOldstyleActions
def _purgeProviders
def _initProviders
def _initOldstyleActions

Static Private Attributes

string _LOGGER_ID = 'actions'

Detailed Description

XML im- and exporter for ActionsTool.

Definition at line 100 of file actions.py.


Member Function Documentation

Export the object as a DOM node.

Definition at line 111 of file actions.py.

00111 
00112     def _exportNode(self):
00113         """Export the object as a DOM node.
00114         """
00115         node = self._getObjectNode('object')
00116         node.setAttribute('xmlns:i18n', I18NURI)
00117         node.appendChild(self._extractProviders())
00118         node.appendChild(self._extractObjects())
00119 
00120         self._logger.info('Actions tool exported.')
00121         return node

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 145 of file actions.py.

00145 
00146     def _extractOldstyleActions(self, provider_id):
00147         # BBB: for CMF 1.6 profiles
00148         fragment = self._doc.createDocumentFragment()
00149 
00150         provider = getToolByName(self.context, provider_id)
00151         if not (IActionProvider.providedBy(provider) or
00152                 z2IActionProvider.isImplementedBy(provider)):
00153             return fragment
00154 
00155         if provider_id == 'portal_actions':
00156             actions = provider._actions
00157         else:
00158             actions = provider.listActions()
00159 
00160         if actions and isinstance(actions[0], dict):
00161             return fragment
00162 
00163         for ai in actions:
00164             mapping = ai.getMapping()
00165             child = self._doc.createElement('action')
00166             child.setAttribute('action_id', mapping['id'])
00167             child.setAttribute('category', mapping['category'])
00168             child.setAttribute('condition_expr', mapping['condition'])
00169             child.setAttribute('title', mapping['title'])
00170             child.setAttribute('url_expr', mapping['action'])
00171             child.setAttribute('visible', str(mapping['visible']))
00172             for permission in mapping['permissions']:
00173                 sub = self._doc.createElement('permission')
00174                 sub.appendChild(self._doc.createTextNode(permission))
00175                 child.appendChild(sub)
00176             fragment.appendChild(child)
00177         return fragment

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 134 of file actions.py.

00134 
00135     def _extractProviders(self):
00136         fragment = self._doc.createDocumentFragment()
00137         for provider_id in self.context.listActionProviders():
00138             child = self._doc.createElement('action-provider')
00139             child.setAttribute('name', provider_id)
00140             # BBB: for CMF 1.6 profiles
00141             sub = self._extractOldstyleActions(provider_id)
00142             child.appendChild(sub)
00143             fragment.appendChild(child)
00144         return fragment

Here is the call graph for this function:

Here is the caller graph for this function:

Import the object from the DOM node.

Definition at line 122 of file actions.py.

00122 
00123     def _importNode(self, node):
00124         """Import the object from the DOM node.
00125         """
00126         if self.environ.shouldPurge():
00127             self._purgeProviders()
00128             self._purgeObjects()
00129 
00130         self._initObjects(node)
00131         self._initProviders(node)
00132 
00133         self._logger.info('Actions tool imported.')

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 200 of file actions.py.

00200 
00201     def _initOldstyleActions(self, node):
00202         # BBB: for CMF 1.6 profiles
00203         doc = node.ownerDocument
00204         fragment = doc.createDocumentFragment()
00205         for child in node.childNodes:
00206             if child.nodeName != 'action':
00207                 continue
00208 
00209             parent = fragment
00210             for category_id in child.getAttribute('category').split('/'):
00211                 newnode = doc.createElement('object')
00212                 newnode.setAttribute('name', str(category_id))
00213                 newnode.setAttribute('meta_type', 'CMF Action Category')
00214                 newnode.setAttribute('purge', 'False')
00215                 parent.appendChild(newnode)
00216                 parent = newnode
00217             newnode = doc.createElement('object')
00218             newnode.setAttribute('name', str(child.getAttribute('action_id')))
00219             newnode.setAttribute('meta_type', 'CMF Action')
00220             newnode.setAttribute('purge', 'False')
00221 
00222             mapping = {'title': 'title',
00223                        'url_expr': 'url_expr',
00224                        'condition_expr': 'available_expr',
00225                        'visible': 'visible'}
00226             for old, new in mapping.iteritems():
00227                 newchild = doc.createElement('property')
00228                 newchild.setAttribute('name', new)
00229                 newsub = doc.createTextNode(child.getAttribute(old))
00230                 newchild.appendChild(newsub)
00231                 newnode.appendChild(newchild)
00232 
00233             newchild = doc.createElement('property')
00234             newchild.setAttribute('name', 'permissions')
00235             for sub in child.childNodes:
00236                 if sub.nodeName == 'permission':
00237                     newsub = doc.createElement('element')
00238                     newsub.setAttribute('value', self._getNodeText(sub))
00239                     newchild.appendChild(newsub)
00240             newnode.appendChild(newchild)
00241 
00242             parent.appendChild(newnode)
00243 
00244         self._initObjects(fragment)
00245 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 182 of file actions.py.

00182 
00183     def _initProviders(self, node):
00184         for child in node.childNodes:
00185             if child.nodeName != 'action-provider':
00186                 continue
00187 
00188             provider_id = str(child.getAttribute('name'))
00189             if child.hasAttribute('remove'):
00190                 if provider_id in self.context.listActionProviders():
00191                     self.context.deleteActionProvider(provider_id)
00192                 continue
00193 
00194             if provider_id in _SPECIAL_PROVIDERS and \
00195                     provider_id not in self.context.listActionProviders():
00196                 self.context.addActionProvider(provider_id)
00197 
00198             # BBB: for CMF 1.6 profiles
00199             self._initOldstyleActions(child)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 178 of file actions.py.

00178 
00179     def _purgeProviders(self):
00180         for provider_id in self.context.listActionProviders():
00181             self.context.deleteActionProvider(provider_id)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 107 of file actions.py.

Definition at line 109 of file actions.py.


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