Commit f21091fc authored by Casey Duncan's avatar Casey Duncan

Reduce catalog brains tendancy to eat conflict errors which could result in rand

om loss of valid results in high-concurrency situations. This problem is especially bad for applications (like CMF) that rely on catalog results as a way to get
 a list of objects to act on.
parent e76730af
...@@ -30,25 +30,24 @@ class AbstractCatalogBrain(Record.Record, Acquisition.Implicit): ...@@ -30,25 +30,24 @@ class AbstractCatalogBrain(Record.Record, Acquisition.Implicit):
return self.aq_parent.getpath(self.data_record_id_) return self.aq_parent.getpath(self.data_record_id_)
def getURL(self, relative=0): def getURL(self, relative=0):
"""Try to generate a URL for this record""" """Generate a URL for this record"""
try: # XXX The previous implementation attempted to eat errors coming from
return self.REQUEST.physicalPathToURL(self.getPath(), relative) # REQUEST.physicalPathToURL. Unfortunately it also ate
except: # ConflictErrors (from getPath), which is bad. Staring at the
return self.getPath() # relevent code in HTTPRequest.py it's unclear to me what could be
# raised by it so I'm removing the exception handling here all
# together. If undesired exceptions get raised somehow we should
# avoid bare except band-aids and find a real solution.
return self.REQUEST.physicalPathToURL(self.getPath(), relative)
def getObject(self, REQUEST=None): def getObject(self, REQUEST=None):
"""Try to return the object for this record""" """Return the object for this record
try:
obj = self.aq_parent.unrestrictedTraverse(self.getPath()) Will return None if the object cannot be found via its cataloged path
if not obj: (i.e., it was deleted or moved without recataloging), or if the user is
if REQUEST is None: not authorized to access an object along the path.
REQUEST = self.REQUEST """
obj = self.aq_parent.resolve_url(self.getPath(), REQUEST) return self.aq_parent.restrictedTraverse(self.getPath(), None)
return obj
except:
zLOG.LOG('CatalogBrains', zLOG.INFO, 'getObject raised an error',
error=sys.exc_info())
pass
def getRID(self): def getRID(self):
"""Return the record ID for this object.""" """Return the record ID for this object."""
......
...@@ -462,7 +462,7 @@ class testRS(unittest.TestCase): ...@@ -462,7 +462,7 @@ class testRS(unittest.TestCase):
self._catalog.aq_parent = objRS(200) self._catalog.aq_parent = objRS(200)
def testRangeSearch(self): def testRangeSearch(self):
for i in range(10000): for i in range(1000):
m = random.randrange(0,20000) m = random.randrange(0,20000)
n = m + 1000 n = m + 1000
......
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