Commit e651972e authored by Ivan Tyagov's avatar Ivan Tyagov

Add upgrader alarm that is able to handle migration of embedded "File" &...

Add upgrader alarm that is able to handle migration of embedded "File" & "Image" objects to "Embedded File" portal type.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41977 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5c648295
##############################################################################
#
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
def migrateToEmbeddedFile(self):
""" Migrate all embedded "File" and "Image"
objects to an unified "Embedded File
"""
from Products.ERP5.Extensions.CheckPortalTypes import changeObjectClass
from Products.ERP5.Document.EmbeddedFile import EmbeddedFile
if self.getPortalType() in ('File', 'Image',) and \
self.getValidationState()=='embedded':
changeObjectClass(self.getParentValue(), self.id, EmbeddedFile)
instance = getattr(self.getParentValue(), self.id)
instance.portal_type = EmbeddedFile.portal_type
instance.reindexObject()
self.log("Migrated %s" %self.getRelativeUrl())
return self.getRelativeUrl()
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>ERP5Site_migrateToEmbeddedFile</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>This alarm when triggered will migrate all embedded "File" and "Image" objects to an unified "Embedded File".</string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>upgrader_migrate_to_embedded_file</string> </value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1294012800.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Migration to Embedded File portal type</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>migrateToEmbeddedFile</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>BaseMigration</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_migrateToEmbeddedFile</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
This script when triggered will migrate all embedded "File" and "Image" \n
objects to an unified "Embedded File".\n
"""\n
active_process = context.getPortalObject().portal_activities.newActiveProcess()\n
context.ERP5Site_checkDataWithScript("Base_migrateToEmbeddedFile", \n
tag="migrate",\n
active_process=active_process.getPath())\n
\n
\n
print "Migration started with process id: %s" %active_process.getPath()\n
return printed\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_migrateToEmbeddedFile</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2011-01-04 Ivan
* Add upgrader alarm that is able to handle migration of embedded "File" & "Image" objects to "Embedded File" portal type
2010-12-23 Kazuhiko
* use my_filename instead of my_source_reference in File_view and Image_view.
......
924
\ No newline at end of file
927
\ No newline at end of file
BaseMigration
\ No newline at end of file
portal_alarms/upgrader_migrate_to_embedded_file
portal_caches/document_cache_factory
portal_caches/document_cache_factory/**
portal_categories/collect_order_group/cell
......
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