[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 = [] |
---|
[2331] | 21 | # for col in self._extractColumns()._get_childNodes(): |
---|
| 22 | # columns.append(col.attributes.items()[0][1]) |
---|
| 23 | for col in self.context.schema(): |
---|
| 24 | columns.append(col) |
---|
[445] | 25 | inds = {} |
---|
[2331] | 26 | # for ind in self._extractIndexes()._get_childNodes(): |
---|
| 27 | # inds[ind.attributes.items()[1][1]] = ind.attributes.items()[0][1] |
---|
| 28 | for ind in self.context.getIndexObjects(): |
---|
| 29 | inds[ind.getId()] = ind.meta_type |
---|
[1936] | 30 | if meta_type in ('CMF Catalog',"WAeUP Table"): |
---|
[2331] | 31 | self._logger.info("Working on %s" % na[1][1]) |
---|
[445] | 32 | for ch in node._get_childNodes(): |
---|
| 33 | if ch.nodeName in ('index',): |
---|
| 34 | cha = ch.attributes.items() |
---|
| 35 | iname = cha[1][1] |
---|
| 36 | itype = cha[0][1] |
---|
| 37 | if iname in inds.keys() and inds[iname] == itype: |
---|
| 38 | continue |
---|
[1062] | 39 | new_indexes.append(iname) |
---|
[1936] | 40 | something_changed = True |
---|
[445] | 41 | elif ch.nodeName in ('column',): |
---|
| 42 | cha = ch.attributes.items() |
---|
| 43 | iname = cha[0][1] |
---|
| 44 | if iname in columns: |
---|
| 45 | continue |
---|
[1062] | 46 | new_columns.append(iname) |
---|
[1936] | 47 | something_changed = True |
---|
[445] | 48 | else: |
---|
| 49 | continue |
---|
[1936] | 50 | if something_changed : |
---|
[2331] | 51 | #import pdb;pdb.set_trace() |
---|
[1935] | 52 | self._logger.info("Catalog tool %s cleared." % na[1][1]) |
---|
[1629] | 53 | self._logger.info("%s modified." % na[1][1]) |
---|
[1804] | 54 | self._initProperties(node) |
---|
[1629] | 55 | if new_indexes and len(self.context()) == 0: #disable creation of new indexes if records in the table |
---|
[2331] | 56 | self._initObjects(node) |
---|
[1629] | 57 | self._initIndexes(node) |
---|
[559] | 58 | self._initColumns(node) |
---|
[1620] | 59 | #self._refreshCatalog() |
---|
[445] | 60 | |
---|
[1936] | 61 | self._logger.info("Catalog tool %s imported." % na[1][1]) |
---|
[445] | 62 | |
---|
| 63 | from Products.CPSCore.exportimport.catalog import CatalogToolXMLAdapter |
---|
| 64 | CatalogToolXMLAdapter._importNode = _importNode |
---|