Back to index

plone3  3.1.7
Private Member Functions | Static Private Attributes
ATContentTypes.exportimport.atcttool.ATCTToolXMLAdapter Class Reference
Inheritance diagram for ATContentTypes.exportimport.atcttool.ATCTToolXMLAdapter:
Inheritance graph
[legend]
Collaboration diagram for ATContentTypes.exportimport.atcttool.ATCTToolXMLAdapter:
Collaboration graph
[legend]

List of all members.

Private Member Functions

def _exportNode
def _importNode
def _purgeSettings
def _initSettings
def _extractSettings

Static Private Attributes

 __used_for__ = IATCTTool

Detailed Description

Node in- and exporter for ATCTTool.

Definition at line 17 of file atcttool.py.


Member Function Documentation

Export the object as a DOM node.

Definition at line 22 of file atcttool.py.

00022 
00023     def _exportNode(self):
00024         """Export the object as a DOM node.
00025         """
00026         node=self._doc.createElement('atcttool')
00027         node.appendChild(self._extractSettings())
00028         node.appendChild(self._extractProperties())
00029 
00030         self._logger.info('ATCTTool settings exported.')
00031         return node

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 114 of file atcttool.py.

00114 
00115     def _extractSettings(self):
00116         fragment = self._doc.createDocumentFragment()
00117         # topic tool indexes
00118         indexes=self._doc.createElement('topic_indexes')
00119         for indexname in self.context.getIndexes():
00120             index = self.context.getIndex(indexname)
00121             child=self._doc.createElement('index')
00122             child.setAttribute('name', str(indexname))
00123             child.setAttribute('friendlyName', str(index.friendlyName))
00124             child.setAttribute('description', str(index.description))
00125             child.setAttribute('enabled', str(bool(index.enabled)))
00126             for criteria in index.criteria:
00127                 if criteria != 'criterion':
00128                     sub = self._doc.createElement('criteria')
00129                     sub.appendChild(self._doc.createTextNode(criteria))
00130                     child.appendChild(sub)
00131             indexes.appendChild(child)
00132         fragment.appendChild(indexes)
00133         # topic tool metadata
00134         metadata=self._doc.createElement('topic_metadata')
00135         for metaname in self.context.getAllMetadata():
00136             meta = self.context.getMetadata(metaname)
00137             child=self._doc.createElement('metadata')
00138             child.setAttribute('name', str(metaname))
00139             child.setAttribute('friendlyName', str(meta.friendlyName))
00140             child.setAttribute('description', str(meta.description))
00141             child.setAttribute('enabled', str(bool(meta.enabled)))
00142             metadata.appendChild(child)
00143         fragment.appendChild(metadata)
00144         
00145         return fragment

Here is the caller graph for this function:

Definition at line 32 of file atcttool.py.

00032 
00033     def _importNode(self, node):
00034         purge = self.environ.shouldPurge()
00035         if node.getAttribute('purge'):
00036             purge = self._convertToBoolean(node.getAttribute('purge'))
00037 
00038         if purge:
00039             self._purgeSettings()
00040             self._purgeProperties()
00041 
00042         self._initSettings(node)
00043         self._initProperties(node)
00044         self._logger.info('ATCTTool settings imported.')

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 53 of file atcttool.py.

00053 
00054     def _initSettings(self, node):
00055         for child in node.childNodes:
00056             if child.nodeName=='topic_indexes':
00057                 for indexNode in child.childNodes:
00058                     if indexNode.nodeName=='index':
00059                         name=indexNode.getAttribute('name')
00060                         if indexNode.hasAttribute("remove"):
00061                             self.context.removeIndex(name)
00062                             continue
00063 
00064                         try:
00065                             self.context.getIndex(name)
00066                         except AttributeError:
00067                             self.context.addIndex(name)
00068 
00069                         description=safeGetAttribute(indexNode, 'description')
00070                         enabled=safeGetAttribute(indexNode, 'enabled')
00071                         if enabled is not None:
00072                             enabled=self._convertToBoolean(enabled)
00073                         friendlyName=safeGetAttribute(indexNode, 'friendlyName')
00074 
00075                         criteria = None
00076                         for critNode in indexNode.childNodes:
00077                             if critNode.nodeName == 'criteria':
00078                                 for textNode in critNode.childNodes:
00079                                     if textNode.nodeName != '#text' or \
00080                                         not textNode.nodeValue.strip():
00081                                         continue
00082                                     if criteria is None:
00083                                         criteria = []
00084                                     criteria.append(str(textNode.nodeValue))
00085                     
00086                         self.context.updateIndex(name,
00087                                               friendlyName=friendlyName,
00088                                               description=description,
00089                                               enabled=enabled,
00090                                               criteria=criteria)
00091                     
00092             if child.nodeName=='topic_metadata':
00093                 for metadataNode in child.childNodes:
00094                     if metadataNode.nodeName=='metadata':
00095                         name=metadataNode.getAttribute('name')
00096                         if metadataNode.hasAttribute("remove"):
00097                             self.context.removeMetadata(name)
00098                             continue
00099 
00100                         try:
00101                             self.context.getMetadata(name)
00102                         except AttributeError:
00103                             self.context.addMetadata(name)
00104 
00105                         description=safeGetAttribute(metadataNode, 'description')
00106                         enabled=safeGetAttribute(metadataNode, 'enabled')
00107                         if enabled is not None:
00108                             enabled=self._convertToBoolean(enabled)
00109                         friendlyName=safeGetAttribute(metadataNode, 'friendlyName')
00110                         self.context.updateMetadata(name,
00111                                                  friendlyName=friendlyName,
00112                                                  description=description,
00113                                                  enabled=enabled)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 45 of file atcttool.py.

00045 
00046     def _purgeSettings(self):
00047         # initialize topic tool
00048         self.context.topic_indexes = {}
00049         self.context.topic_metadata = {}
00050         self.context.allowed_portal_types = []
00051         self.context.createInitialIndexes()
00052         self.context.createInitialMetadata()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 20 of file atcttool.py.


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