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
'migrateSourceCodeFromFilesystem')
def migrateSourceCodeFromFilesystem(self,
version,
erase_existing=False,
**kw):
"""
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
try:
obj = temp_obj.importFromFilesystem(component_tool,
temp_obj.getReference(),
version,
erase_existing=erase_existing)
version)
except Exception, e:
import traceback
LOG("BusinessTemplate", WARNING,
......
......@@ -95,7 +95,6 @@
<key> <string>left</string> </key>
<value>
<list>
<string>your_erase_existing</string>
<string>your_version</string>
</list>
</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):
Return the ID prefix for Component objects
"""
def importFromFilesystem(cls, context, reference, version,
erase_existing=False):
def importFromFilesystem(cls, context, reference, version):
"""
Import a Component from the filesystem into ZODB after checking that the
source code is valid
......
......@@ -345,25 +345,12 @@ class ComponentMixin(PropertyRecordableMixin, Base):
security.declareProtected(Permissions.ModifyPortalContent,
'importFromFilesystem')
@classmethod
def importFromFilesystem(cls, context, reference, version,
erase_existing=False):
def importFromFilesystem(cls, context, reference, version):
"""
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
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
path = os.path.join(cls._getFilesystemPath(), reference + '.py')
with open(path) as f:
......@@ -373,6 +360,7 @@ class ComponentMixin(PropertyRecordableMixin, Base):
# needed when importing from filesystem, moreover errors may occur
# if in the same transaction a Component is created and another
# one depending upon the former...
object_id = '%s.%s.%s' % (cls._getIdPrefix(), version, reference)
new_component = context.newContent(id=object_id,
reference=reference,
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