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

Revert "Traverse on returned paths in order to calculate security."

This reverts commit c5409c67.
parent a8651ba1
...@@ -147,7 +147,6 @@ class SlapTool(BaseTool): ...@@ -147,7 +147,6 @@ class SlapTool(BaseTool):
def _getCacheComputerInformation(self, computer_id, user, full): def _getCacheComputerInformation(self, computer_id, user, full):
self.REQUEST.response.setHeader('Content-Type', 'text/xml') self.REQUEST.response.setHeader('Content-Type', 'text/xml')
restrictedTraverse = self.getPortalObject().restrictedTraverse
slap_computer = Computer(computer_id) slap_computer = Computer(computer_id)
parent_uid = self._getComputerUidByReference(computer_id) parent_uid = self._getComputerUidByReference(computer_id)
...@@ -159,8 +158,7 @@ class SlapTool(BaseTool): ...@@ -159,8 +158,7 @@ class SlapTool(BaseTool):
validation_state="validated", validation_state="validated",
portal_type="Computer Partition"): portal_type="Computer Partition"):
slap_computer._computer_partition_list.append( slap_computer._computer_partition_list.append(
self._getSlapPartitionByPackingList( self._getSlapPartitionByPackingList(computer_partition.getObject()))
restrictedTraverse(computer_partition.PATH)))
return xml_marshaller.xml_marshaller.dumps(slap_computer) return xml_marshaller.xml_marshaller.dumps(slap_computer)
def _fillComputerInformationCache(self, computer_id, user, full): def _fillComputerInformationCache(self, computer_id, user, full):
...@@ -202,11 +200,8 @@ class SlapTool(BaseTool): ...@@ -202,11 +200,8 @@ class SlapTool(BaseTool):
computer_id, user, full) computer_id, user, full)
def _getComputerInformation(self, computer_id, user, full): def _getComputerInformation(self, computer_id, user, full):
restrictedTraverse = self.getPortalObject().restrictedTraverse user_document = self.getPortalObject().portal_catalog.unrestrictedGetResultValue(
user_document = self.getPortalObject().portal_catalog\ reference=user, portal_type=['Person', 'Computer', 'Software Instance'])
.unrestrictedSearchResults(reference=user,
portal_type=['Person', 'Computer', 'Software Instance'])[0].PATH
user_document = restrictedTraverse(user_document)
user_type = user_document.getPortalType() user_type = user_document.getPortalType()
self.REQUEST.response.setHeader('Content-Type', 'text/xml') self.REQUEST.response.setHeader('Content-Type', 'text/xml')
slap_computer = Computer(computer_id) slap_computer = Computer(computer_id)
...@@ -239,7 +234,7 @@ class SlapTool(BaseTool): ...@@ -239,7 +234,7 @@ class SlapTool(BaseTool):
validation_state="validated", validation_state="validated",
portal_type="Computer Partition"): portal_type="Computer Partition"):
slap_computer._computer_partition_list.append( slap_computer._computer_partition_list.append(
self._getSlapPartitionByPackingList(restrictedTraverse(computer_partition.PATH))) self._getSlapPartitionByPackingList(computer_partition.getObject()))
return xml_marshaller.xml_marshaller.dumps(slap_computer) return xml_marshaller.xml_marshaller.dumps(slap_computer)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
...@@ -551,8 +546,6 @@ class SlapTool(BaseTool): ...@@ -551,8 +546,6 @@ class SlapTool(BaseTool):
validation_state="validated", validation_state="validated",
limit=2, limit=2,
) )
software_instance_list = [portal.restrictedTraverse(x.PATH) for x \
in software_instance_list]
software_instance_count = len(software_instance_list) software_instance_count = len(software_instance_list)
if software_instance_count == 1: if software_instance_count == 1:
software_instance = software_instance_list[0].getObject() software_instance = software_instance_list[0].getObject()
...@@ -685,8 +678,6 @@ class SlapTool(BaseTool): ...@@ -685,8 +678,6 @@ class SlapTool(BaseTool):
validation_state="validated", validation_state="validated",
limit=2, limit=2,
) )
software_instance_list = [portal.restrictedTraverse(x.PATH) for x \
in software_instance_list]
software_instance_count = len(software_instance_list) software_instance_count = len(software_instance_list)
if software_instance_count == 1: if software_instance_count == 1:
software_instance = software_instance_list[0].getObject() software_instance = software_instance_list[0].getObject()
...@@ -1118,13 +1109,11 @@ class SlapTool(BaseTool): ...@@ -1118,13 +1109,11 @@ class SlapTool(BaseTool):
def _getDocument(self, **kwargs): def _getDocument(self, **kwargs):
# No need to get all results if an error is raised when at least 2 objects # No need to get all results if an error is raised when at least 2 objects
# are found # are found
portal = self.getPortalObject() l = self.getPortalObject().portal_catalog.unrestrictedSearchResults(limit=2, **kwargs)
l = portal.portal_catalog.unrestrictedSearchResults(limit=2, **kwargs)
l = [portal.restrictedTraverse(x.PATH) for x in l]
if len(l) != 1: if len(l) != 1:
raise NotFound, "No document found with parameters: %s" % kwargs raise NotFound, "No document found with parameters: %s" % kwargs
else: else:
return l[0] return l[0].getObject()
def _getNonCachedComputerDocument(self, computer_reference): def _getNonCachedComputerDocument(self, computer_reference):
return self._getDocument( return self._getDocument(
...@@ -1171,11 +1160,10 @@ class SlapTool(BaseTool): ...@@ -1171,11 +1160,10 @@ class SlapTool(BaseTool):
limit=2, limit=2,
url_string={'query': url, 'key': 'ExactMatch'}, url_string={'query': url, 'key': 'ExactMatch'},
) )
software_installation_list = [self.getPortalObject()\
.restrictedTraverse(x.PATH) for x in software_installation_list]
l = len(software_installation_list) l = len(software_installation_list)
if l == 1: if l == 1:
return software_installation_list[0] return software_installation_list[0].getObject()
elif l == 0: elif l == 0:
raise NotFound('No software release %r found on computer %r' % (url, raise NotFound('No software release %r found on computer %r' % (url,
computer_document.getReference())) computer_document.getReference()))
...@@ -1206,14 +1194,12 @@ class SlapTool(BaseTool): ...@@ -1206,14 +1194,12 @@ class SlapTool(BaseTool):
else: else:
query_kw['reference'] = slave_reference query_kw['reference'] = slave_reference
software_instance = [self.getPortalObject().restrictedTraverse(x.PATH) \ software_instance = self.getPortalObject().portal_catalog.unrestrictedGetResultValue(**query_kw)
for x in self.getPortalObject().portal_catalog\ if software_instance is None:
.unrestrictedSearchResults(**query_kw)]
if len(software_instance) == 0 is None:
raise NotFound, "No software instance found for: %s - %s" % ( raise NotFound, "No software instance found for: %s - %s" % (
computer_id, computer_partition_id) computer_id, computer_partition_id)
else: else:
return software_instance[0] return software_instance
@UnrestrictedMethod @UnrestrictedMethod
def _getSoftwareInstanceAsParameterDict(self, software_instance): def _getSoftwareInstanceAsParameterDict(self, software_instance):
...@@ -1238,7 +1224,7 @@ class SlapTool(BaseTool): ...@@ -1238,7 +1224,7 @@ class SlapTool(BaseTool):
validation_state="validated", validation_state="validated",
) )
for slave_instance in slave_instance_sql_list: for slave_instance in slave_instance_sql_list:
slave_instance = portal.restrictedTraverse(slave_instance.PATH) slave_instance = slave_instance.getObject()
# XXX Use catalog to filter more efficiently # XXX Use catalog to filter more efficiently
if slave_instance.getSlapState() == "start_requested": if slave_instance.getSlapState() == "start_requested":
append({ append({
...@@ -1275,7 +1261,6 @@ class SlapTool(BaseTool): ...@@ -1275,7 +1261,6 @@ class SlapTool(BaseTool):
default_aggregate_uid=computer_document.getUid(), default_aggregate_uid=computer_document.getUid(),
validation_state='validated', validation_state='validated',
): ):
software_installation = portal.restrictedTraverse(software_installation.PATH)
software_release_response = SoftwareRelease( software_release_response = SoftwareRelease(
software_release=software_installation.getUrlString(), software_release=software_installation.getUrlString(),
computer_guid=computer_reference) computer_guid=computer_reference)
......
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