source: WAeUP_SRP/trunk/PatchCatalogToolXMLAdapter.py @ 1935

Last change on this file since 1935 was 1935, checked in by joachim, 17 years ago

avoid clearing of portal_catalog_real

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