Commit a34f7caa authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_prototype: Update Business Package to use ObjectPropertyTemplateItem

parent 60ebe529
...@@ -142,7 +142,7 @@ class BusinessPackage(XMLObject): ...@@ -142,7 +142,7 @@ class BusinessPackage(XMLObject):
def _install(self, **kw): def _install(self, **kw):
self._path_item.install(self) self._path_item.install(self)
#self._object_property_item.install(self) self._object_property_item.install(self)
security.declareProtected(Permissions.ManagePortal, 'install') security.declareProtected(Permissions.ManagePortal, 'install')
install = _install install = _install
...@@ -158,16 +158,16 @@ class BusinessPackage(XMLObject): ...@@ -158,16 +158,16 @@ class BusinessPackage(XMLObject):
""" """
if not no_action: if not no_action:
self.storePathData() self.storePathData()
# XXX: Explicitly calling build for items. Needs to be changed
self._path_item.build(self) self._path_item.build(self)
self._object_property_item.build(self)
pass pass
#self._object_property_item.build(self)
#self.setBuildingState('built')
security.declareProtected(Permissions.ManagePortal, 'storePathData') security.declareProtected(Permissions.ManagePortal, 'storePathData')
def storePathData(self): def storePathData(self):
self._path_item = PathTemplatePackageItem(self._getTemplatePathList()) self._path_item = PathTemplatePackageItem(self._getTemplatePathList())
#self._object_property_item = \ self._object_property_item = \
# ObjectPropertyTemplatePackageItem(self._getTemplateObjectPropertyList()) ObjectPropertyTemplatePackageItem(self._getTemplateObjectPropertyList())
security.declareProtected(Permissions.ManagePortal, 'getTemplatePathList') security.declareProtected(Permissions.ManagePortal, 'getTemplatePathList')
def _getTemplateObjectPropertyList(self): def _getTemplateObjectPropertyList(self):
...@@ -220,7 +220,7 @@ class BusinessPackage(XMLObject): ...@@ -220,7 +220,7 @@ class BusinessPackage(XMLObject):
elif prop_type in ('lines', 'tokens'): elif prop_type in ('lines', 'tokens'):
bpa.addObject('\n'.join(value), name=id, path='bt', ext='') bpa.addObject('\n'.join(value), name=id, path='bt', ext='')
item_name_list = ['_path_item',] item_name_list = ['_path_item', '_object_property_item']
# Export each part # Export each part
for item_name in item_name_list: for item_name in item_name_list:
item = getattr(self, item_name, None) item = getattr(self, item_name, None)
...@@ -250,10 +250,12 @@ class BusinessPackage(XMLObject): ...@@ -250,10 +250,12 @@ class BusinessPackage(XMLObject):
prop_dict[pid] = value or 0 prop_dict[pid] = value or 0
elif prop_type in ('lines', 'tokens'): elif prop_type in ('lines', 'tokens'):
prop_dict[pid[:-5]] = (value or '').splitlines() prop_dict[pid[:-5]] = (value or '').splitlines()
# XXX: This is not working, needs to be fixed so as it copies all the
# properties from BPA to the newly created Business Package
self._edit(**prop_dict) self._edit(**prop_dict)
self.storePathData() self.storePathData()
item_name_list = ['_path_item',] item_name_list = ['_path_item', '_object_property_item']
for item_name in item_name_list: for item_name in item_name_list:
item_object = getattr(self, item_name, None) item_object = getattr(self, item_name, None)
# this check is due to backwards compatability when there can be a # this check is due to backwards compatability when there can be a
...@@ -726,8 +728,8 @@ class PathTemplatePackageItem(Implicit, Persistent): ...@@ -726,8 +728,8 @@ class PathTemplatePackageItem(Implicit, Persistent):
if getattr(aq_base(obj), 'reindexObject', None) is not None: if getattr(aq_base(obj), 'reindexObject', None) is not None:
obj.reindexObject() obj.reindexObject()
def importFile(self, bta, **kw): def importFile(self, bpa, **kw):
bta.importFiles(self) bpa.importFiles(self)
def _importFile(self, file_name, file_obj, catalog_method_template_item = 0): def _importFile(self, file_name, file_obj, catalog_method_template_item = 0):
obj_key, file_ext = os.path.splitext(file_name) obj_key, file_ext = os.path.splitext(file_name)
...@@ -882,6 +884,9 @@ class ObjectPropertyTemplatePackageItem(Implicit, Persistent): ...@@ -882,6 +884,9 @@ class ObjectPropertyTemplatePackageItem(Implicit, Persistent):
xml_data = self.generateXml() xml_data = self.generateXml()
bpa.addObject(xml_data, name=self.xml_tag, path=path) bpa.addObject(xml_data, name=self.xml_tag, path=path)
def importFile(self, bpa, **kw):
bpa.importFiles(self)
def _importFile(self, file_name, file): def _importFile(self, file_name, file):
if not file_name.endswith('.xml'): if not file_name.endswith('.xml'):
LOG('Business Template', 0, 'Skipping file "%s"' % (file_name, )) LOG('Business Template', 0, 'Skipping file "%s"' % (file_name, ))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment