Commit 8d2817c7 authored by 's avatar

Fixed a nasty bug where non-existent objects that caused a Not Found

during resolve_url caused the exception method of the (cloned) response
object to be called. This mean that as soon as an error occurred during
resolve_url, the transaction would be aborted and things got extremely
weird since objects that had been uncataloged would suddenly be back
(due to the abort).
parent 886b9557
......@@ -429,26 +429,59 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
roles.sort()
return roles
## stolen from ZPublisher and modified slightly
## Note: do not use, this method is depricated. Use 'getobject'
def resolve_url(self, path, REQUEST):
"""
Attempt to resolve a url into an object in the Zope
namespace. The url may be absolute or a catalog path
style url. If no object is found, None is returned.
No exceptions are raised.
"""
script=REQUEST.script
if string.find(path, script) != 0:
path='%s/%s' % (script, path)
# NOTE - DO NOT CHANGE THIS! The semantics required for url
# resolution are _different_ for the catalog (and probably
# DAV as well), and this needs to remain until we can think
# harder about the resolve_url interface!
print "resolving", path
try:
return REQUEST.resolve_url(path)
def resolve_url(self, path, REQUEST):
""" """
while path and path[0]=='/': path=path[1:]
while path and path[-1]=='/': path=path[:-1]
req=REQUEST.clone()
rsp=req.response
req['PATH_INFO']=path
object=None
try: object=req.traverse(path)
except:
print "not found"
return None
# Do NOT call rsp.exception here!
pass
if object is not None:
if hasattr(object, 'id'):
if callable(object.id):
name=object.id()
else: name=object.id
elif hasattr(object, '__name__'):
name=object.__name__
else: name=''
if name != os.path.split(path)[-1]:
result = req.PARENTS[0]
req.close()
return result
req.close()
return object
req.close()
raise rsp.errmsg, sys.exc_value
## def resolve_url(self, path, REQUEST):
## """
## Attempt to resolve a url into an object in the Zope
## namespace. The url may be absolute or a catalog path
## style url. If no object is found, None is returned.
## No exceptions are raised.
## """
## script=REQUEST.script
## if string.find(path, script) != 0:
## path='%s/%s' % (script, path)
## print "resolving", path
## try:
## return REQUEST.resolve_url(path)
## except:
## print "not found"
## return None
Globals.default__class_init__(ZCatalog)
......
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