Back to index

plone3  3.1.7
Static Public Attributes | Private Member Functions | Static Private Attributes
CMFPlone.exportimport.controlpanel.ControlPanelXMLAdapter Class Reference
Inheritance diagram for CMFPlone.exportimport.controlpanel.ControlPanelXMLAdapter:
Inheritance graph
[legend]
Collaboration diagram for CMFPlone.exportimport.controlpanel.ControlPanelXMLAdapter:
Collaboration graph
[legend]

List of all members.

Static Public Attributes

string name = 'controlpanel'

Private Member Functions

def _exportNode
def _importNode
def _initProvider
def _extractConfiglets
def _initConfiglets

Static Private Attributes

 __used_for__ = IControlPanel
string _LOGGER_ID = 'controlpanel'

Detailed Description

XML im- and exporter for Plone control panel.  Most of this
code is taken from the actions handler in CMFCore.

Definition at line 29 of file controlpanel.py.


Member Function Documentation

Export the object as a DOM node.

Definition at line 42 of file controlpanel.py.

00042 
00043     def _exportNode(self):
00044         """
00045         Export the object as a DOM node.
00046         """
00047         node = self._getObjectNode('object')
00048         node.appendChild(self._extractConfiglets())
00049         self._logger.info('Control panel exported.')
00050         return node

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 66 of file controlpanel.py.

00066 
00067     def _extractConfiglets(self):
00068         fragment = self._doc.createDocumentFragment()
00069 
00070         provider = self.context
00071         if not (IActionProvider.providedBy(provider) or
00072                 z2IActionProvider.isImplementedBy(provider)):
00073             return fragment
00074 
00075         actions = provider.listActions()
00076 
00077         if actions and isinstance(actions[0], dict):
00078             return fragment
00079 
00080         for ai in actions:
00081             mapping = ai.getMapping()
00082             child = self._doc.createElement('configlet')
00083             child.setAttribute('action_id', mapping['id'])
00084             child.setAttribute('category', mapping['category'])
00085             child.setAttribute('condition_expr', mapping['condition'])
00086             child.setAttribute('title', mapping['title'])
00087             child.setAttribute('url_expr', mapping['action'])
00088             child.setAttribute('visible', str(mapping['visible']))
00089             child.setAttribute('appId', ai.getAppId())
00090             for permission in mapping['permissions']:
00091                 sub = self._doc.createElement('permission')
00092                 sub.appendChild(self._doc.createTextNode(permission))
00093                 child.appendChild(sub)
00094             fragment.appendChild(child)
00095         return fragment
00096 

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 51 of file controlpanel.py.

00051 
00052     def _importNode(self, node):
00053         """
00054         Import the object from the DOM node.
00055         """
00056         self._initProvider(node)
00057         self._logger.info('Control panel imported.')

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 97 of file controlpanel.py.

00097 
00098     def _initConfiglets(self, node):
00099         controlpanel = self.context
00100         for child in node.childNodes:
00101             if child.nodeName != 'configlet':
00102                 continue
00103 
00104             action_id = str(child.getAttribute('action_id'))
00105             title = str(child.getAttribute('title'))
00106             url_expr = str(child.getAttribute('url_expr'))
00107             condition_expr = str(child.getAttribute('condition_expr'))
00108             category = str(child.getAttribute('category'))
00109             visible = str(child.getAttribute('visible'))
00110             appId = str(child.getAttribute('appId'))
00111             if visible.lower() == 'true':
00112                 visible = 1
00113             else:
00114                 visible = 0
00115 
00116             permission = ''
00117             for permNode in child.childNodes:
00118                 if permNode.nodeName == 'permission':
00119                     for textNode in permNode.childNodes:
00120                         if textNode.nodeName != '#text' or \
00121                                not textNode.nodeValue.strip():
00122                             continue
00123                         permission = str(textNode.nodeValue)
00124                         break  # only one permission is allowed
00125                     if permission:
00126                         break
00127 
00128             # Remove previous action with same id and category.
00129             controlpanel.unregisterConfiglet(action_id)
00130 
00131             controlpanel.registerConfiglet(id=action_id,
00132                                            name=title,
00133                                            action=url_expr,
00134                                            appId=appId,
00135                                            condition=condition_expr,
00136                                            category=category,
00137                                            permission=permission,
00138                                            visible=visible)
00139 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 58 of file controlpanel.py.

00058 
00059     def _initProvider(self, node):
00060         if self.environ.shouldPurge():
00061             actions = self.context.listActions()
00062             for action in actions:
00063                 self.context.unregisterConfiglet(action.getId())
00064 
00065         self._initConfiglets(node)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 36 of file controlpanel.py.

Definition at line 38 of file controlpanel.py.

Definition at line 40 of file controlpanel.py.


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