source: WAeUP_SRP/branches/uli/PatchCatalogToolXMLAdapter.py @ 10565

Last change on this file since 10565 was 1653, checked in by uli, 18 years ago

Incorporated changeset 1593:1652 of trunk into uli-branch.

  • Property svn:keywords set to Id
File size: 2.1 KB
RevLine 
[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
6def _importNode(self, node):
7    """Import the object from the DOM node.
8    """
[502]9    #import pdb;pdb.set_trace()
[445]10    if self.environ.shouldPurge():
11        self._purgeProperties()
12        self._purgeObjects()
13        self._purgeIndexes()
14        self._purgeColumns()
15    columns = []
16    for col in self._extractColumns()._get_childNodes():
17        columns.append(col.attributes.items()[0][1])
18    #print "cols: ",columns
19    inds = {}
20    for ind in self._extractIndexes()._get_childNodes():
21        inds[ind.attributes.items()[1][1]] = ind.attributes.items()[0][1]
22        #print ind.attributes.items()
[1653]23    #from pdb import set_trace; set_trace()
[445]24    na = node.attributes.items()
25    not_found = True
[1062]26    new_indexes = []
27    new_columns = []
[1653]28    if na[0][1] in ("CMF Catalog","WAeUP Table"):
[502]29        #print na[1][1]
[1062]30        not_found = False
[445]31        for ch in node._get_childNodes():
32            if ch.nodeName in ('index',):
33                cha = ch.attributes.items()
34                iname = cha[1][1]
35                itype = cha[0][1]
36                if iname in inds.keys() and inds[iname] == itype:
37                    continue
[1062]38                new_indexes.append(iname)
[445]39            elif ch.nodeName in ('column',):
40                cha = ch.attributes.items()
41                iname = cha[0][1]
42                if iname in columns:
43                    continue
[1062]44                new_columns.append(iname)
[445]45            else:
46                continue
47            not_found = True
48    if not_found:
[1653]49        self._logger.info("%s modified." % na[1][1])
50        #self._initProperties(node)
51        #self._initObjects(node)
52        if new_indexes and len(self.context()) == 0: #disable creation of new indexes if records in the table
53            self._initIndexes(node)
[559]54        self._initColumns(node)
[1653]55        #self._refreshCatalog()
[445]56
[1653]57    self._logger.info("Catalog tool %s imported."  % na[1][1])
[445]58   
59from Products.CPSCore.exportimport.catalog import CatalogToolXMLAdapter
60CatalogToolXMLAdapter._importNode = _importNode
Note: See TracBrowser for help on using the repository browser.