source: WAeUP_SRP/trunk/patches/PatchCatalogToolXMLAdapter.py @ 17628

Last change on this file since 17628 was 3673, checked in by jens, 16 years ago
  • unclutter package by moving all patch files into a dedicated subfolder and importing it.
  • Property svn:keywords set to Id
File size: 2.4 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    something_changed = False
11    new_indexes = []
12    new_columns = []
13    meta_type = na[0][1]
14    name = na[1][1]
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    for col in self.context.schema():
24        columns.append(col)
25    inds = {}
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
30    if meta_type in ('CMF Catalog',"WAeUP Table"):
31        self._logger.info("Working on %s"  % na[1][1])
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
39                new_indexes.append(iname)
40                something_changed = True
41            elif ch.nodeName in ('column',):
42                cha = ch.attributes.items()
43                iname = cha[0][1]
44                if iname in columns:
45                    continue
46                new_columns.append(iname)
47                something_changed = True
48            else:
49                continue
50    if something_changed :
51        #import pdb;pdb.set_trace()
52        self._logger.info("Catalog tool %s cleared."  % na[1][1])
53        self._logger.info("%s modified." % na[1][1])
54        self._initProperties(node)
55        if new_indexes and len(self.context()) == 0: #disable creation of new indexes if records in the table
56            self._initObjects(node)
57            self._initIndexes(node)
58        self._initColumns(node)
59        #self._refreshCatalog()
60
61    self._logger.info("Catalog tool %s imported."  % na[1][1])
62   
63from Products.CPSCore.exportimport.catalog import CatalogToolXMLAdapter
64CatalogToolXMLAdapter._importNode = _importNode
Note: See TracBrowser for help on using the repository browser.