[445] | 1 | #from Products.CMFCore.utils import getToolByName |
---|
| 2 | #from zope.app import zapi |
---|
| 3 | #from Products.GenericSetup.interfaces import INode |
---|
| 4 | #import Products |
---|
| 5 | |
---|
| 6 | def _importNode(self, node): |
---|
| 7 | """Import the object from the DOM node. |
---|
| 8 | """ |
---|
[1935] | 9 | na = node.attributes.items() |
---|
[1936] | 10 | something_changed = False |
---|
[1935] | 11 | new_indexes = [] |
---|
| 12 | new_columns = [] |
---|
| 13 | meta_type = na[0][1] |
---|
| 14 | name = na[1][1] |
---|
[445] | 15 | if self.environ.shouldPurge(): |
---|
| 16 | self._purgeProperties() |
---|
| 17 | self._purgeObjects() |
---|
| 18 | self._purgeIndexes() |
---|
| 19 | self._purgeColumns() |
---|
| 20 | columns = [] |
---|
| 21 | for col in self._extractColumns()._get_childNodes(): |
---|
| 22 | columns.append(col.attributes.items()[0][1]) |
---|
| 23 | inds = {} |
---|
| 24 | for ind in self._extractIndexes()._get_childNodes(): |
---|
| 25 | inds[ind.attributes.items()[1][1]] = ind.attributes.items()[0][1] |
---|
[1936] | 26 | if meta_type in ('CMF Catalog',"WAeUP Table"): |
---|
[445] | 27 | for ch in node._get_childNodes(): |
---|
| 28 | if ch.nodeName in ('index',): |
---|
| 29 | cha = ch.attributes.items() |
---|
| 30 | iname = cha[1][1] |
---|
| 31 | itype = cha[0][1] |
---|
| 32 | if iname in inds.keys() and inds[iname] == itype: |
---|
| 33 | continue |
---|
[1062] | 34 | new_indexes.append(iname) |
---|
[1936] | 35 | something_changed = True |
---|
[445] | 36 | elif ch.nodeName in ('column',): |
---|
| 37 | cha = ch.attributes.items() |
---|
| 38 | iname = cha[0][1] |
---|
| 39 | if iname in columns: |
---|
| 40 | continue |
---|
[1062] | 41 | new_columns.append(iname) |
---|
[1936] | 42 | something_changed = True |
---|
[445] | 43 | else: |
---|
| 44 | continue |
---|
[1936] | 45 | if something_changed : |
---|
[1935] | 46 | self._logger.info("Catalog tool %s cleared." % na[1][1]) |
---|
[1629] | 47 | self._logger.info("%s modified." % na[1][1]) |
---|
[1804] | 48 | self._initProperties(node) |
---|
| 49 | self._initObjects(node) |
---|
[1629] | 50 | if new_indexes and len(self.context()) == 0: #disable creation of new indexes if records in the table |
---|
| 51 | self._initIndexes(node) |
---|
[559] | 52 | self._initColumns(node) |
---|
[1620] | 53 | #self._refreshCatalog() |
---|
[445] | 54 | |
---|
[1936] | 55 | self._logger.info("Catalog tool %s imported." % na[1][1]) |
---|
[445] | 56 | |
---|
| 57 | from Products.CPSCore.exportimport.catalog import CatalogToolXMLAdapter |
---|
| 58 | CatalogToolXMLAdapter._importNode = _importNode |
---|