Commit fd0b8d89 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Fix bang propagation as Slave Instance

parent c6fbdfb2
......@@ -27,7 +27,9 @@
from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager, newSecurityManager
from Products import ERP5Security
from Products.ERP5Type.UnrestrictedMethod import super_user
def SoftwareInstance_bangAsSelf(self, relative_url=None, reference=None,
comment=None):
......@@ -37,21 +39,19 @@ def SoftwareInstance_bangAsSelf(self, relative_url=None, reference=None,
raise TypeError('relative_url has to be defined')
if reference is None:
raise TypeError('reference has to be defined')
# micro security: can caller access software instance?
software_instance = self.restrictedTraverse(relative_url)
sm = getSecurityManager()
if (software_instance.getPortalType() == "Slave Instance") and \
(software_instance.getReference() == reference):
# XXX There is no account for Slave Instance
user_id = ERP5Security.SUPER_USER
else:
user_id = software_instance.getUserId()
with super_user():
software_instance.bang(bang_tree=True, comment=comment)
return
newSecurityManager(None, self.getPortalObject().acl_users.getUserById(
user_id))
sm = getSecurityManager()
user_id = software_instance.getUserId()
newSecurityManager(None, self.getPortalObject().acl_users.getUserById(user_id))
try:
software_instance.bang(bang_tree=True, comment=comment)
finally:
# Restore the original user.
setSecurityManager(sm)
\ No newline at end of file
......@@ -6,10 +6,22 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SlapOSCloud</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>extension.erp5.SlapOSCloud</string> </value>
......@@ -43,13 +55,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -62,7 +89,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -71,7 +98,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
......@@ -52,6 +52,14 @@
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Instance_checkConsistency</string> </value>
......
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