durusmail: quixote-users: .get_directory_path() problem
.get_directory_path() problem
2004-11-26
2004-11-28
2004-11-29
2004-11-29
2004-11-29
.get_directory_path() problem
Mike Orr
2004-11-26
I'm updating my program to Quixote 2.0a2, and discovered the new
..get_directory_path() breaks my output filter.

My filter goes up the directory path (=namespace stack) applying any
_q_filter_output methods it finds.  In Quixote 1.2, Publisher.namespace_stack
was a list that remained throughout the request.  In Quixote 2.0a2,
quixote.util.get_directory_path() generates the list from the current Python
stack frame (=traceback stack).  That's fine if it's called from inside the
callable (=servlet), but if called from Publish.filter_output() it returns []
because those functions have exited.  ("Those functions" being the recursive
Directory._q_traverse() calls, from which it finds the Directory instances.)

As a workaround I've put the info in the request since it's request-specific.

class Publisher(_Publisher):
    def start_request(self):
        req = quixote.get_request()
        req.directory_path = []
        _Publisher.start_request(self)  # Old-style class :(.

    def filter_output(self, req, output):
        stack = req.directory_path[:]
        ...

class Directory(_Directory):
    def _q_traverse(self, path):
        req = quixote.get_request()
        req.directory_path.append(self)
        return super(Directory, self)._q_traverse(path)

Any chance this or something equivalent can be put into the core?

--
-Mike Orr (aka. Sluggo), mso@oz.net  (iron@sense-sea-MegaSub-1-465.oz.net)
   http://sluggo.kicks-ass.org/                  Cxu vi parolas Esperante?

reply