source: WAeUP_SRP/trunk/PatchCatalogToolXMLAdapter.py @ 1508

Last change on this file since 1508 was 1062, checked in by joachim, 18 years ago

add search for serial No

  • Property svn:keywords set to Id
File size: 2.0 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()
23    #print "indexes: ", inds
24    na = node.attributes.items()
25    not_found = True
[1062]26    new_indexes = []
27    new_columns = []
28    if na[0][1] in ("WAeUP Table"):
[445]29        not_found = False
[1062]30    elif na[0][1] == "CMF Catalog":
[502]31        #print na[1][1]
[1062]32        not_found = False
[445]33        for ch in node._get_childNodes():
34            if ch.nodeName in ('index',):
35                cha = ch.attributes.items()
36                iname = cha[1][1]
37                itype = cha[0][1]
38                if iname in inds.keys() and inds[iname] == itype:
39                    continue
[1062]40                new_indexes.append(iname)
[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)
[445]47            else:
48                continue
49            not_found = True
50    if not_found:
[559]51        self._initProperties(node)
52        self._initObjects(node)
53        self._initIndexes(node)
54        self._initColumns(node)
[445]55        self._refreshCatalog()
56
57    self._logger.info("Catalog tool imported.")
58   
59from Products.CPSCore.exportimport.catalog import CatalogToolXMLAdapter
60CatalogToolXMLAdapter._importNode = _importNode
Note: See TracBrowser for help on using the repository browser.