durusmail: quixote-users: _get_component must return a publishing object
_get_component must return a publishing object
2003-08-07
2003-08-07
2003-08-07
2003-08-07
_get_component must return a publishing object
Oleg Broytmann
2003-08-07
Hi! Another problem.

   My program is publishing objects with URLs like this:
http://host-ru/files/resources/ID/?page=1
   IDs are pointers to a DB, and must be intergers. There are many IDs, so
there is no point tu put them into _q_access. The only way to handle them
is _q_lookup, right?

class Resources:
   def _q_lookup(self, request, id):
      try:
         id = int(id)
      except ValueError:
         return request.redirect("http://host-ru/error-page")

   Oops...

   There is a loop
    # Loop over the components of the path
    for component in path_components:
        if component == "":
            # "/q/foo/" == "/q/foo/_q_index"
            component = "_q_index"
        object = _get_component(object, component, path, request,
                               namespace_stack)

in publish.py, in _traverse_url. The problem is that the loop is continuing
to traverse objects even if _get_component returned non-traversable object
(string, in my case). On the next call to _get_component quixote raise an
exception "... has no _q_exports list".
   Shouldn't the loop stops after _get_component returned non-traversable
object?

Oleg.
--
     Oleg Broytmann            http://phd.pp.ru/            phd@phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

reply