Back to index

plone3  3.1.7
Static Public Attributes | Private Member Functions | Static Private Attributes
GenericSetup.ZCatalog.exportimport.ZCatalogXMLAdapter Class Reference
Inheritance diagram for GenericSetup.ZCatalog.exportimport.ZCatalogXMLAdapter:
Inheritance graph
[legend]
Collaboration diagram for GenericSetup.ZCatalog.exportimport.ZCatalogXMLAdapter:
Collaboration graph
[legend]

List of all members.

Static Public Attributes

string name = 'catalog'

Private Member Functions

def _exportNode
def _importNode
def _extractIndexes
def _purgeIndexes
def _initIndexes
def _extractColumns
def _purgeColumns
def _initColumns

Static Private Attributes

string _LOGGER_ID = 'catalog'

Detailed Description

XML im- and exporter for ZCatalog.

Definition at line 36 of file exportimport.py.


Member Function Documentation

Export the object as a DOM node.

Definition at line 47 of file exportimport.py.

00047 
00048     def _exportNode(self):
00049         """Export the object as a DOM node.
00050         """
00051         node = self._getObjectNode('object')
00052         node.appendChild(self._extractProperties())
00053         node.appendChild(self._extractObjects())
00054         node.appendChild(self._extractIndexes())
00055         node.appendChild(self._extractColumns())
00056 
00057         self._logger.info('Catalog exported.')
00058         return node

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 123 of file exportimport.py.

00123 
00124     def _extractColumns(self):
00125         fragment = self._doc.createDocumentFragment()
00126         schema = self.context.schema()[:]
00127         schema.sort()
00128         for col in schema:
00129             child = self._doc.createElement('column')
00130             child.setAttribute('value', col)
00131             fragment.appendChild(child)
00132         return fragment

Here is the caller graph for this function:

Definition at line 75 of file exportimport.py.

00075 
00076     def _extractIndexes(self):
00077         fragment = self._doc.createDocumentFragment()
00078         indexes = self.context.getIndexObjects()[:]
00079         indexes.sort(lambda x,y: cmp(x.getId(), y.getId()))
00080         for idx in indexes:
00081             exporter = queryMultiAdapter((idx, self.environ), INode)
00082             if exporter:
00083                 fragment.appendChild(exporter.node)
00084         return fragment

Here is the caller graph for this function:

Import the object from the DOM node.

Definition at line 59 of file exportimport.py.

00059 
00060     def _importNode(self, node):
00061         """Import the object from the DOM node.
00062         """
00063         if self.environ.shouldPurge():
00064             self._purgeProperties()
00065             self._purgeObjects()
00066             self._purgeIndexes()
00067             self._purgeColumns()
00068 
00069         self._initProperties(node)
00070         self._initObjects(node)
00071         self._initIndexes(node)
00072         self._initColumns(node)
00073 
00074         self._logger.info('Catalog imported.')

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 137 of file exportimport.py.

00137 
00138     def _initColumns(self, node):
00139         for child in node.childNodes:
00140             if child.nodeName != 'column':
00141                 continue
00142             col = str(child.getAttribute('value'))
00143             if child.hasAttribute('remove'):
00144                 # Remove the column if it is there
00145                 if col in self.context.schema()[:]:
00146                     self.context.delColumn(col)
00147                 continue
00148             if col not in self.context.schema()[:]:
00149                 self.context.addColumn(col)
00150 

Here is the caller graph for this function:

Definition at line 89 of file exportimport.py.

00089 
00090     def _initIndexes(self, node):
00091         for child in node.childNodes:
00092             if child.nodeName != 'index':
00093                 continue
00094             if child.hasAttribute('deprecated'):
00095                 continue
00096             zcatalog = self.context
00097 
00098             idx_id = str(child.getAttribute('name'))
00099             if child.hasAttribute('remove'):
00100                 # Remove index if it is there; then continue to the next
00101                 # index.  Removing a non existing index should not cause an
00102                 # error, so you can apply the profile twice without problems.
00103                 if idx_id in zcatalog.indexes():
00104                     zcatalog.delIndex(idx_id)
00105                 continue
00106 
00107             if idx_id not in zcatalog.indexes():
00108                 extra = _extra()
00109                 for sub in child.childNodes:
00110                     if sub.nodeName == 'extra':
00111                         name = str(sub.getAttribute('name'))
00112                         value = str(sub.getAttribute('value'))
00113                         setattr(extra, name, value)
00114                 extra = extra.__dict__ and extra or None
00115 
00116                 meta_type = str(child.getAttribute('meta_type'))
00117                 zcatalog.addIndex(idx_id, meta_type, extra)
00118 
00119             idx = zcatalog._catalog.getIndex(idx_id)
00120             importer = queryMultiAdapter((idx, self.environ), INode)
00121             if importer:
00122                 importer.node = child

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 133 of file exportimport.py.

00133 
00134     def _purgeColumns(self):
00135         for col in self.context.schema()[:]:
00136             self.context.delColumn(col)

Here is the caller graph for this function:

Definition at line 85 of file exportimport.py.

00085 
00086     def _purgeIndexes(self):
00087         for idx_id in self.context.indexes():
00088             self.context.delIndex(idx_id)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 43 of file exportimport.py.

Definition at line 45 of file exportimport.py.


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