Commit c07d4339 authored by Łukasz Nowak's avatar Łukasz Nowak

Switch to instance user before doing bang.

parent fcd9bd97
......@@ -61,6 +61,20 @@ def restrictMethodAsShadowUser(self, open_order=None, callable_object=None,
# Restore the original user.
setSecurityManager(sm)
def SoftwareInstance_bangAsSelf(self, relative_url=None, reference=None,
comment=None):
"""Call bang on self."""
# micro security: can caller access software instance?
software_instance = self.restrictedTraverse(relative_url)
sm = getSecurityManager()
newSecurityManager(None, self.getPortalObject().acl_users.getUserById(
reference))
try:
software_instance.reportComputerPartitionBang(comment=comment)
finally:
# Restore the original user.
setSecurityManager(sm)
def getComputerSecurityCategory(self, base_category_list, user_name,
object, portal_type):
"""
......
<?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>SoftwareInstance_bangAsSelf</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>VifibSecurity</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_bangAsSelf</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
289
\ No newline at end of file
290
\ No newline at end of file
......@@ -55,7 +55,8 @@ for computer_partition in [x for x in computer.contentValues(portal_type=\'Compu
# raises ValueError in case of no packing list found, left as is\n
packing_list_line = computer_partition.Item_getInstancePackingListLine()\n
software_instance = packing_list_line.getAggregateValue(portal_type=\'Software Instance\')\n
software_instance.activate().reportComputerPartitionBang(comment=state_change.kwargs.get(\'comment\', \'\'))\n
software_instance.activate().SoftwareInstance_bangAsSelf(reference=software_instance.getReference(),\n
comment=state_change.kwargs.get(\'comment\', \'\'))\n
</string> </value>
</item>
<item>
......
440
\ No newline at end of file
441
\ 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