Back to index

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

List of all members.

Private Member Functions

def _exportNode
def _importNode
def _extractAliases
def _purgeAliases
def _initAliases
def _extractActions
def _purgeActions
def _initActions

Static Private Attributes

string _LOGGER_ID = 'types'

Detailed Description

XML im- and exporter for TypeInformation.

Definition at line 33 of file typeinfo.py.


Member Function Documentation

Export the object as a DOM node.

Definition at line 42 of file typeinfo.py.

00042 
00043     def _exportNode(self):
00044         """Export the object as a DOM node.
00045         """
00046         node = self._getObjectNode('object')
00047         node.setAttribute('xmlns:i18n', I18NURI)
00048         node.appendChild(self._extractProperties())
00049         node.appendChild(self._extractAliases())
00050         node.appendChild(self._extractActions())
00051 
00052         self._logger.info('%r type info exported.' % self.context.getId())
00053         return node

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 93 of file typeinfo.py.

00093 
00094     def _extractActions(self):
00095         fragment = self._doc.createDocumentFragment()
00096         actions = self.context.listActions()
00097         for ai in actions:
00098             ai_info = ai.getMapping()
00099             child = self._doc.createElement('action')
00100             child.setAttribute('title', ai_info['title'])
00101             child.setAttribute('action_id', ai_info['id'])
00102             child.setAttribute('category', ai_info['category'])
00103             child.setAttribute('condition_expr', ai_info['condition'])
00104             child.setAttribute('url_expr', ai_info['action'])
00105             child.setAttribute('visible', str(bool(ai_info['visible'])))
00106             for permission in ai_info['permissions']:
00107                 sub = self._doc.createElement('permission')
00108                 sub.setAttribute('value', permission)
00109                 child.appendChild(sub)
00110             fragment.appendChild(child)
00111         return fragment

Here is the caller graph for this function:

Definition at line 69 of file typeinfo.py.

00069 
00070     def _extractAliases(self):
00071         fragment = self._doc.createDocumentFragment()
00072         aliases = self.context.getMethodAliases().items()
00073         aliases.sort()
00074         for k, v in aliases:
00075             child = self._doc.createElement('alias')
00076             child.setAttribute('from', k)
00077             child.setAttribute('to', v)
00078             fragment.appendChild(child)
00079         return fragment

Here is the caller graph for this function:

Import the object from the DOM node.

Definition at line 54 of file typeinfo.py.

00054 
00055     def _importNode(self, node):
00056         """Import the object from the DOM node.
00057         """
00058         if self.environ.shouldPurge():
00059             self._purgeProperties()
00060             self._purgeAliases()
00061             self._purgeActions()
00062 
00063         self._initProperties(node)
00064         self._initAliases(node)
00065         self._initActions(node)
00066 
00067         obj_id = str(node.getAttribute('name'))
00068         self._logger.info('%r type info imported.' % obj_id)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 115 of file typeinfo.py.

00115 
00116     def _initActions(self, node):
00117         for child in node.childNodes:
00118             if child.nodeName != 'action':
00119                 continue
00120             title = str(child.getAttribute('title'))
00121             id = str(child.getAttribute('action_id'))
00122             category = str(child.getAttribute('category'))
00123             condition = str(child.getAttribute('condition_expr'))
00124             action = str(child.getAttribute('url_expr'))
00125             visible = self._convertToBoolean(child.getAttribute('visible'))
00126             permissions = []
00127             for sub in child.childNodes:
00128                 if sub.nodeName != 'permission':
00129                     continue
00130                 permission = sub.getAttribute('value')
00131                 permissions.append(permission)
00132             action_obj = self.context.getActionObject(category+'/'+id)
00133             if action_obj is None:
00134                 self.context.addAction(id, title, action, condition,
00135                                        tuple(permissions), category, visible)
00136             else:
00137                 action_obj.edit(title=title, action=action,
00138                                 condition=condition,
00139                                 permissions=tuple(permissions),
00140                                 visible=visible)
00141 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 83 of file typeinfo.py.

00083 
00084     def _initAliases(self, node):
00085         aliases = self.context.getMethodAliases()
00086         for child in node.childNodes:
00087             if child.nodeName != 'alias':
00088                 continue
00089             k = str(child.getAttribute('from'))
00090             v = str(child.getAttribute('to'))
00091             aliases[k] = v
00092         self.context.setMethodAliases(aliases)

Here is the caller graph for this function:

Definition at line 112 of file typeinfo.py.

00112 
00113     def _purgeActions(self):
00114         self.context._actions = ()

Here is the caller graph for this function:

Definition at line 80 of file typeinfo.py.

00080 
00081     def _purgeAliases(self):
00082         self.context.setMethodAliases({})

Here is the caller graph for this function:


Member Data Documentation

Definition at line 40 of file typeinfo.py.


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