Commit 11b7de08 authored by Łukasz Nowak's avatar Łukasz Nowak

Migrate url_string of instances.

parent 422d6ebc
from Products.ERP5Type.Base import WorkflowMethod
def Instance_migrateUrlString(obj):
@WorkflowMethod.disable
def real(obj):
property_id = 'root_software_release_url'
if obj.getPortalType() not in ('Hosting Subscription', 'Software Instance', 'Slave Instance'):
raise TypeError(obj.getPortalType())
old_url = getattr(obj.aq_base, property_id, None)
new_url = obj.getUrlString()
if not old_url and not new_url:
raise ValueError('%s has no url defined at all' % obj.getPath())
if old_url:
obj.setUrlString(old_url)
assert(obj.getUrlString() == old_url)
delattr(obj.aq_base, property_id)
if type(obj) == type([]):
for o in obj:
real(o[0])
else:
real(obj)
<?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>portal = context.getPortalObject()\n
tag = script.id\n
method_id = \'Instance_migrateUrlString\'\n
for module in (\n
portal.hosting_subscription_module,\n
portal.software_instance_module,\n
):\n
module.recurseCallMethod(\n
method_id,\n
max_depth=1,\n
min_depth=1,\n
max_retry=0,\n
activity_count=50,\n
activate_kw={\n
\'tag\': script.id,\n
\'group_method_id\': method_id,\n
\'group_method_cost\': 1./50, # fire up 50 activities in same transaction\n
}\n
)\n
\n
return \'Done.\'\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>00_ERP5Site_migrateUrlString</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>Instance_migrateUrlString</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>SlapOSUpgrader</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Instance_migrateUrlString</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
5
\ No newline at end of file
6
\ No newline at end of file
SlapOSUpgrader
\ No newline at end of file
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