Commit 68a50590 authored by Antoine Catton's avatar Antoine Catton

Adding renamming capability.

parent 5f2398a2
<?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># Get the software_instance\n
software_instance = state_change[\'object\']\n
\n
# Change the title\n
software_instance.edit(title=state_change.kwargs[\'new_name\'])\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_rename</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Rename software instance</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -24,6 +24,7 @@
<tuple>
<string>destroy_computer_partition</string>
<string>destroy_requested</string>
<string>rename</string>
<string>report_computer_partition_bang</string>
<string>report_computer_partition_error</string>
<string>request_computer_partition</string>
......
......@@ -24,6 +24,7 @@
<tuple>
<string>destroy_computer_partition</string>
<string>destroy_requested</string>
<string>rename</string>
<string>report_computer_partition_bang</string>
<string>report_computer_partition_error</string>
<string>request_computer_partition</string>
......
......@@ -24,6 +24,7 @@
<tuple>
<string>destroy_computer_partition</string>
<string>destroy_requested</string>
<string>rename</string>
<string>report_computer_partition_bang</string>
<string>report_computer_partition_error</string>
<string>request_computer_partition</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>SoftwareInstance_rename</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rename</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Rename Software Instance</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
325
\ No newline at end of file
326
\ No newline at end of file
......@@ -245,6 +245,14 @@ class SlapTool(BaseTool):
return self._softwareInstanceError(computer_id, computer_partition_id,
error_log)
security.declareProtected(Permissions.AccessContentsInformation,
'softwareInstanceRename')
def softwareInstanceRename(self, new_name, computer_id,
computer_partition_id, slave_reference=None):
return self._softwareInstanceRename(new_name, computer_id,
computer_partition_id,
slave_reference)
security.declareProtected(Permissions.AccessContentsInformation,
'softwareInstanceBang')
def softwareInstanceBang(self, computer_id,
......@@ -626,6 +634,15 @@ class SlapTool(BaseTool):
computer_partition_id).reportComputerPartitionError(
comment=error_log)
@convertToREST
def _softwareInstanceRename(self, new_name, computer_id,
computer_partition_id, slave_reference):
software_instance = self._getSoftwareInstanceForComputerPartition(
computer_id, computer_partition_id,
slave_reference)
return software_instance.rename(new_name=new_name,
comment="Rename %s into %s" % (software_instance.title, new_name))
@convertToREST
def _softwareInstanceBang(self, computer_id,
computer_partition_id, message):
......
......@@ -378,6 +378,14 @@ class ComputerPartition(SlapDocument):
'computer_partition_id': self._partition_id,
'message': message})
def rename(self, new_name, slave_reference=None):
self._connection_helper.POST('/rename', {
'computer_id': self._computer_id,
'computer_partition_id': self._computer_id,
'new_name': new_name,
'slave_reference': slave_reference,
})
def getId(self):
return self._partition_id
......
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