Changeset 1760 in products for quintagroup.catalogupdater/trunk/quintagroup/catalogupdater/exportimport
- Timestamp:
- Feb 17, 2010 1:38:20 PM (14 years ago)
- Location:
- quintagroup.catalogupdater/trunk/quintagroup/catalogupdater/exportimport
- Files:
-
- 1 added
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.catalogupdater/trunk/quintagroup/catalogupdater/exportimport/catalogupdater.py
r1759 r1760 4 4 from zope.component import queryUtility 5 5 6 from Products.CMFCore.utils import getToolByName 7 from Products.GenericSetup.utils import importObjects 8 from Products.GenericSetup.utils import XMLAdapterBase 6 from Products.ZCatalog.interfaces import IZCatalog 9 7 from Products.GenericSetup.interfaces import ISetupEnviron 8 from Products.GenericSetup.ZCatalog.exportimport import ZCatalogXMLAdapter 10 9 11 from quintagroup.catalogupdater.interfaces import I UpdatableCatalog10 from quintagroup.catalogupdater.interfaces import ICatalogUpdater 12 11 13 12 14 class CatalogUpdaterXMLAdapter(XMLAdapterBase): 15 """XML Catalog columns updater for CatalogTool. 13 class CatalogUpdaterXMLAdapter(ZCatalogXMLAdapter): 14 """XML im- and exporter for ZCatalog with 15 support of columns updates 16 16 """ 17 17 18 adapts(I UpdatableCatalog, ISetupEnviron)18 adapts(IZCatalog, ISetupEnviron) 19 19 20 _LOGGER_ID = 'catalogupdater' 21 22 name = 'catalogupdater' 23 24 def _exportNode(self): 25 """Export the object as a DOM node. 26 """ 27 return '' 28 29 def _importNode(self, node): 30 """Import the object from the DOM node. 31 """ 32 self._updateColumns(node) 33 self._logger.info('Catalog columns updated.') 34 35 36 def _updateColumns(self, node): 37 columns = [] 20 def _initColumns(self, node): 21 super(CatalogUpdaterXMLAdapter, self)._initColumns(node) 22 import pdb;pdb.set_trace() 23 updatecols = [] 38 24 for child in node.childNodes: 39 25 if child.nodeName != 'column': 40 26 continue 41 col = str(child.getAttribute('value')).strip() 42 columns.append(col) 27 col = str(child.getAttribute('value')) 28 if child.hasAttribute('update'): 29 # Add the column to update list if it is there 30 if col in self.context.schema()[:]: 31 updatecols.append(col) 32 continue 43 33 44 34 # Update columns in catalog 45 if len(columns) > 0: 46 35 if len(updatecols) > 0: 47 36 catalog = self.context 48 37 49 38 self._logger.info('Updating %s columns for %s Catalog.' % ( 50 columns, '/'.join(catalog.getPhysicalPaht())) )39 updatecols, '/'.join(catalog.getPhysicalPaht())) ) 51 40 52 41 cu = queryUtility(ICatalogUpdater, name='catalog_updater') 53 cu.updateMetadata4All(catalog, columns) 54 55 56 def updateCatalogColumns(context): 57 """Update catalog columns with catalog_updater tool. 58 """ 59 site = context.getSite() 60 tool = getToolByName(site, 'portal_catalog') 61 62 importObjects(tool, '', context) 42 cu.updateMetadata4All(catalog, updatecols)
Note: See TracChangeset
for help on using the changeset viewer.