Commit 7bdebea8 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Remove migration from FS 'erase_existing' feature.

Half-broken, not useful after all and potentially harmful once Products
Documents will be migrated from FS.
parent 44874290
...@@ -6323,7 +6323,6 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -6323,7 +6323,6 @@ Business Template is a set of definitions, such as skins, portal types and categ
'migrateSourceCodeFromFilesystem') 'migrateSourceCodeFromFilesystem')
def migrateSourceCodeFromFilesystem(self, def migrateSourceCodeFromFilesystem(self,
version, version,
erase_existing=False,
**kw): **kw):
""" """
Migrate the given components from filesystem to ZODB by calling the Migrate the given components from filesystem to ZODB by calling the
...@@ -6343,8 +6342,7 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -6343,8 +6342,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
try: try:
obj = temp_obj.importFromFilesystem(component_tool, obj = temp_obj.importFromFilesystem(component_tool,
temp_obj.getReference(), temp_obj.getReference(),
version, version)
erase_existing=erase_existing)
except Exception, e: except Exception, e:
import traceback import traceback
LOG("BusinessTemplate", WARNING, LOG("BusinessTemplate", WARNING,
......
...@@ -95,7 +95,6 @@ ...@@ -95,7 +95,6 @@
<key> <string>left</string> </key> <key> <string>left</string> </key>
<value> <value>
<list> <list>
<string>your_erase_existing</string>
<string>your_version</string> <string>your_version</string>
</list> </list>
</value> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_erase_existing</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_checkbox</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Erase Existing</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -68,8 +68,7 @@ class IComponent(Interface): ...@@ -68,8 +68,7 @@ class IComponent(Interface):
Return the ID prefix for Component objects Return the ID prefix for Component objects
""" """
def importFromFilesystem(cls, context, reference, version, def importFromFilesystem(cls, context, reference, version):
erase_existing=False):
""" """
Import a Component from the filesystem into ZODB after checking that the Import a Component from the filesystem into ZODB after checking that the
source code is valid source code is valid
......
...@@ -345,25 +345,12 @@ class ComponentMixin(PropertyRecordableMixin, Base): ...@@ -345,25 +345,12 @@ class ComponentMixin(PropertyRecordableMixin, Base):
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'importFromFilesystem') 'importFromFilesystem')
@classmethod @classmethod
def importFromFilesystem(cls, context, reference, version, def importFromFilesystem(cls, context, reference, version):
erase_existing=False):
""" """
Import a Component from the filesystem into ZODB and validate it so it can Import a Component from the filesystem into ZODB and validate it so it can
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._getIdPrefix(), version, reference)
obj = context._getOb(object_id, None)
if obj is not None:
if not erase_existing:
# Validate the object if it has not been validated yet
if obj.getValidationState() not in ('modified', 'validated'):
obj.validate()
return obj
context.deleteContent(object_id)
import os.path import os.path
path = os.path.join(cls._getFilesystemPath(), reference + '.py') path = os.path.join(cls._getFilesystemPath(), reference + '.py')
with open(path) as f: with open(path) as f:
...@@ -373,6 +360,7 @@ class ComponentMixin(PropertyRecordableMixin, Base): ...@@ -373,6 +360,7 @@ class ComponentMixin(PropertyRecordableMixin, Base):
# needed when importing from filesystem, moreover errors may occur # needed when importing from filesystem, moreover errors may occur
# if in the same transaction a Component is created and another # if in the same transaction a Component is created and another
# one depending upon the former... # one depending upon the former...
object_id = '%s.%s.%s' % (cls._getIdPrefix(), version, reference)
new_component = context.newContent(id=object_id, new_component = context.newContent(id=object_id,
reference=reference, reference=reference,
version=version, version=version,
......
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