--- publish.py.orig 2003-05-27 01:24:43.000000000 -0500 +++ publish.py.patched 2003-06-09 22:23:15.000000000 -0500 @@ -442,11 +442,13 @@ self.start_request(request) + # Initialize the publisher's namespace_stack + self.namespace_stack = [] + # Traverse package to a (hopefully-) callable object - object, namespace_stack = _traverse_url(self.root_namespace, path, - request, - self.config.fix_trailing_slash) - self.namespace_stack = namespace_stack + object = _traverse_url(self.root_namespace, path, request, + self.config.fix_trailing_slash, + self.namespace_stack) # None means no output -- traverse_url() just issued a redirect. if object is None: @@ -623,10 +625,11 @@ _slash_pat = re.compile("//*") -def _traverse_url (root_namespace, path, request, fix_trailing_slash): +def _traverse_url (root_namespace, path, request, fix_trailing_slash, + namespace_stack): """traverse_url(root_namespace : any, path : string, - request : HTTPRequest, fix_trailing_slash : bool) -> - (object : any, [object]) + request : HTTPRequest, fix_trailing_slash : bool, + namespace_stack : dict) -> (object : any) Perform traversal based on the provided path, starting at the root object. It returns the script name and path info values for @@ -643,6 +646,10 @@ names. Not having a _q_exports attribute is an error, though having _q_exports be an empty list is OK. If a component of the path isn't in _q_exports, that also produces an error. + + Modifies the namespace_stack as it traverses the url, so that + any exceptions encountered along the way can be handled by the + nearest handler. """ # If someone accesses a Quixote driver script without a trailing @@ -654,7 +661,7 @@ if (not path and fix_trailing_slash): request.redirect(request.environ['SCRIPT_NAME'] + '/' , permanent=1) - return None, [] + return None # replace repeated slashes with a single slash if path.find("//") != -1: @@ -666,7 +673,7 @@ # Traverse starting at the root object = root_namespace - namespace_stack = [object] + namespace_stack.append(object) # Loop over the components of the path for component in path_components: @@ -686,7 +693,7 @@ # Repair the path and redirect. This should not happen for # URLs within the site. request.redirect(request.get_path() + "/", permanent=1) - return None, [] + return None else: # Automatic redirects disabled or there is form data. If @@ -704,7 +711,7 @@ private_msg=repr(object), path=path) - return object, namespace_stack + return object def _get_component (container, component, path, request, namespace_stack):