Commit db59da79 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Simplify the Extension code when bangAsSelf

parent c0685e19
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
from AccessControl.SecurityManagement import getSecurityManager, \ from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager, newSecurityManager setSecurityManager, newSecurityManager
from Products.ERP5Security import SUPER_USER
from Products.ERP5Type.UnrestrictedMethod import super_user
from zExceptions import Unauthorized from zExceptions import Unauthorized
from DateTime import DateTime from DateTime import DateTime
...@@ -45,17 +45,15 @@ def SoftwareInstance_bangAsSelf(self, relative_url=None, reference=None, ...@@ -45,17 +45,15 @@ def SoftwareInstance_bangAsSelf(self, relative_url=None, reference=None,
if (software_instance.getPortalType() == "Slave Instance") and \ if (software_instance.getPortalType() == "Slave Instance") and \
(software_instance.getReference() == reference): (software_instance.getReference() == reference):
# XXX There is no account for Slave Instance # XXX There is no account for Slave Instance
with super_user(): user = self.getPortalObject().acl_users.getUser(SUPER_USER)
software_instance.bang(bang_tree=True, comment=comment) else:
return
sm = getSecurityManager()
user_id = software_instance.getUserId() user_id = software_instance.getUserId()
newSecurityManager(None, self.getPortalObject().acl_users.getUserById(user_id)) user = self.getPortalObject().acl_users.getUserById(user_id)
sm = getSecurityManager()
try: try:
newSecurityManager(None, user)
software_instance.bang(bang_tree=True, comment=comment) software_instance.bang(bang_tree=True, comment=comment)
finally: finally:
# Restore the original user.
setSecurityManager(sm) setSecurityManager(sm)
def SoftwareInstance_renameAndRequestDestroy(self, REQUEST=None): def SoftwareInstance_renameAndRequestDestroy(self, REQUEST=None):
......
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