Commit a450e310 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Shorten ID by removing common erp5.component prefix.

parent c8329138
...@@ -3959,6 +3959,8 @@ class ConstraintTemplateItem(FilesystemDocumentTemplateItem): ...@@ -3959,6 +3959,8 @@ class ConstraintTemplateItem(FilesystemDocumentTemplateItem):
local_file_importer_name = staticmethod(importLocalConstraint) local_file_importer_name = staticmethod(importLocalConstraint)
local_file_remover_name = staticmethod(removeLocalConstraint) local_file_remover_name = staticmethod(removeLocalConstraint)
from Products.ERP5Type.Core.DocumentComponent import DocumentComponent
class DocumentTemplateItem(FilesystemToZodbTemplateItem): class DocumentTemplateItem(FilesystemToZodbTemplateItem):
""" """
Documents are now stored in ZODB rather than on the filesystem. However, Documents are now stored in ZODB rather than on the filesystem. However,
...@@ -3984,7 +3986,7 @@ class DocumentTemplateItem(FilesystemToZodbTemplateItem): ...@@ -3984,7 +3986,7 @@ class DocumentTemplateItem(FilesystemToZodbTemplateItem):
@staticmethod @staticmethod
def _getZodbObjectId(id): def _getZodbObjectId(id):
return 'erp5.component.document.' + id return DocumentComponent._getIdPrefix() + '.' + id
@staticmethod @staticmethod
def _getFilesystemPath(class_id): def _getFilesystemPath(class_id):
...@@ -4106,6 +4108,8 @@ class DocumentTemplateItem(FilesystemToZodbTemplateItem): ...@@ -4106,6 +4108,8 @@ class DocumentTemplateItem(FilesystemToZodbTemplateItem):
self.portal_components.reset(force=True, self.portal_components.reset(force=True,
reset_portal_type_at_transaction_boundary=True) reset_portal_type_at_transaction_boundary=True)
from Products.ERP5Type.Core.ExtensionComponent import ExtensionComponent
class ExtensionTemplateItem(DocumentTemplateItem): class ExtensionTemplateItem(DocumentTemplateItem):
""" """
Extensions are now stored in ZODB rather than on the filesystem. However, Extensions are now stored in ZODB rather than on the filesystem. However,
...@@ -4121,11 +4125,13 @@ class ExtensionTemplateItem(DocumentTemplateItem): ...@@ -4121,11 +4125,13 @@ class ExtensionTemplateItem(DocumentTemplateItem):
@staticmethod @staticmethod
def _getZodbObjectId(id): def _getZodbObjectId(id):
return 'erp5.component.extension.' + id return ExtensionComponent._getIdPrefix() + '.' + id
def getTemplateIdList(self): def getTemplateIdList(self):
return self.getTemplateExtensionIdList() return self.getTemplateExtensionIdList()
from Products.ERP5Type.Core.TestComponent import TestComponent
class TestTemplateItem(DocumentTemplateItem): class TestTemplateItem(DocumentTemplateItem):
""" """
Live Tests are now stored in ZODB rather than on the filesystem. However, Live Tests are now stored in ZODB rather than on the filesystem. However,
...@@ -4140,7 +4146,7 @@ class TestTemplateItem(DocumentTemplateItem): ...@@ -4140,7 +4146,7 @@ class TestTemplateItem(DocumentTemplateItem):
@staticmethod @staticmethod
def _getZodbObjectId(id): def _getZodbObjectId(id):
return 'erp5.component.test.' + id return TestComponent._getIdPrefix() + '.' + id
def getTemplateIdList(self): def getTemplateIdList(self):
return self.getTemplateTestIdList() return self.getTemplateTestIdList()
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>python: portal.Base_checkPermission(\'portal_components\', \'Add portal content\') and context.getInstallationState() != \'installed\' and [id_ for id_ in (context.getTemplateExtensionIdList() + context.getTemplateDocumentIdList() + context.getTemplateTestIdList()) if not id_.startswith(\'erp5.component\')]</string> </value> <value> <string>python: portal.Base_checkPermission(\'portal_components\', \'Add portal content\') and context.getInstallationState() != \'installed\' and [id_ for id_ in (context.getTemplateExtensionIdList() + context.getTemplateDocumentIdList() + context.getTemplateTestIdList()) if not id_.startswith(\'extension.\') and not id_.startswith(\'document.\') and not id_.startswith(\'test.\') ]</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
2013-08-23 arnaud.fontaine
* ZODB Components: Shorten ID by removing common erp5.component prefix.
2013-08-20 arnaud.fontaine 2013-08-20 arnaud.fontaine
* ZODB Components: Add field to specify the object paths whose only last workflow history must be kept. * ZODB Components: Add field to specify the object paths whose only last workflow history must be kept.
......
41121 41122
\ No newline at end of file \ No newline at end of file
...@@ -7204,11 +7204,11 @@ class TestDocumentTemplateItem(BusinessTemplateMixin): ...@@ -7204,11 +7204,11 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
component_module = DocumentComponent._getDynamicModuleNamespace() component_id_prefix = DocumentComponent._getIdPrefix()
component_portal_type = DocumentComponent.portal_type component_portal_type = DocumentComponent.portal_type
def stepCreateZodbDocument(self, sequence=None, **kw): def stepCreateZodbDocument(self, sequence=None, **kw):
document_id = self.component_module + '.erp5.' + self.document_title document_id = self.component_id_prefix + '.erp5.' + self.document_title
component = self.portal.portal_components.newContent( component = self.portal.portal_components.newContent(
id=document_id, id=document_id,
version='erp5', version='erp5',
...@@ -7277,7 +7277,7 @@ class TestDocumentTemplateItem(BusinessTemplateMixin): ...@@ -7277,7 +7277,7 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
self.assertTrue(os.path.exists(component_bt_tool_path)) self.assertTrue(os.path.exists(component_bt_tool_path))
component_id = self.component_module + '.erp5.' + sequence['document_title'] component_id = self.component_id_prefix + '.erp5.' + sequence['document_title']
base_path = os.path.join(component_bt_tool_path, component_id) base_path = os.path.join(component_bt_tool_path, component_id)
python_source_code_path = base_path + '.py' python_source_code_path = base_path + '.py'
...@@ -7424,7 +7424,7 @@ class TestDocumentTemplateItem(BusinessTemplateMixin): ...@@ -7424,7 +7424,7 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
Check bt5 migration of Document from the Filesystem to ZODB Check bt5 migration of Document from the Filesystem to ZODB
""" """
bt = sequence.get('current_bt') bt = sequence.get('current_bt')
component_id = '%s.erp5.%s' % (self.component_module, component_id = '%s.erp5.%s' % (self.component_id_prefix,
sequence.get('document_title')) sequence.get('document_title'))
self.assertEquals(bt.getTemplateKeepLastWorkflowHistoryOnlyPathList(), self.assertEquals(bt.getTemplateKeepLastWorkflowHistoryOnlyPathList(),
...@@ -7600,7 +7600,7 @@ class TestExtensionTemplateItem(TestDocumentTemplateItem): ...@@ -7600,7 +7600,7 @@ class TestExtensionTemplateItem(TestDocumentTemplateItem):
template_property = 'template_extension_id_list' template_property = 'template_extension_id_list'
# Specific to ZODB Extension Component # Specific to ZODB Extension Component
component_module = ExtensionComponent._getDynamicModuleNamespace() component_id_prefix = ExtensionComponent._getIdPrefix()
component_portal_type = ExtensionComponent.portal_type component_portal_type = ExtensionComponent.portal_type
from Products.ERP5Type.Core.TestComponent import TestComponent from Products.ERP5Type.Core.TestComponent import TestComponent
...@@ -7619,7 +7619,7 @@ class TestTestTemplateItem(TestDocumentTemplateItem): ...@@ -7619,7 +7619,7 @@ class TestTestTemplateItem(TestDocumentTemplateItem):
template_property = 'template_test_id_list' template_property = 'template_test_id_list'
# Specific to ZODB Extension Component # Specific to ZODB Extension Component
component_module = TestComponent._getDynamicModuleNamespace() component_id_prefix = TestComponent._getIdPrefix()
component_portal_type = TestComponent.portal_type component_portal_type = TestComponent.portal_type
def stepAddTestToBusinessTemplate(self, sequence=None, **kw): def stepAddTestToBusinessTemplate(self, sequence=None, **kw):
......
...@@ -57,3 +57,7 @@ class DocumentComponent(ComponentMixin): ...@@ -57,3 +57,7 @@ class DocumentComponent(ComponentMixin):
@staticmethod @staticmethod
def _getDynamicModuleNamespace(): def _getDynamicModuleNamespace():
return 'erp5.component.document' return 'erp5.component.document'
@staticmethod
def _getIdPrefix():
return 'document'
...@@ -56,3 +56,7 @@ class ExtensionComponent(ComponentMixin): ...@@ -56,3 +56,7 @@ class ExtensionComponent(ComponentMixin):
@staticmethod @staticmethod
def _getDynamicModuleNamespace(): def _getDynamicModuleNamespace():
return 'erp5.component.extension' return 'erp5.component.extension'
@staticmethod
def _getIdPrefix():
return 'extension'
...@@ -57,3 +57,7 @@ class TestComponent(ComponentMixin): ...@@ -57,3 +57,7 @@ class TestComponent(ComponentMixin):
@staticmethod @staticmethod
def _getDynamicModuleNamespace(): def _getDynamicModuleNamespace():
return 'erp5.component.test' return 'erp5.component.test'
@staticmethod
def _getIdPrefix():
return 'test'
...@@ -74,6 +74,11 @@ class IComponent(Interface): ...@@ -74,6 +74,11 @@ class IComponent(Interface):
Return the module name where Component module are loaded into Return the module name where Component module are loaded into
""" """
def _getIdPrefix():
"""
Return the ID prefix for Component objects
"""
def importFromFilesystem(cls, context, reference, version, def importFromFilesystem(cls, context, reference, version,
erase_existing=False): erase_existing=False):
""" """
......
...@@ -361,9 +361,7 @@ class ComponentMixin(PropertyRecordableMixin, Base): ...@@ -361,9 +361,7 @@ class ComponentMixin(PropertyRecordableMixin, Base):
be loaded straightaway provided validate() does not raise any error of be loaded straightaway provided validate() does not raise any error of
course course
""" """
object_id = '%s.%s.%s' % (cls._getDynamicModuleNamespace(), version, object_id = '%s.%s.%s' % (cls._getIdPrefix(), version, reference)
reference)
obj = context._getOb(object_id, None) obj = context._getOb(object_id, None)
if obj is not None: if obj is not None:
if not erase_existing: if not erase_existing:
......
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