Marius Gedminas wrote:
> On Thu, Dec 29, 2005 at 11:22:28PM -0700, Jeff Shell wrote:
>>Again, this is to have URLs like:
>>And turn that into a catalog search for anyof {'zope', 'viewlet'}
>>    def publishTraverse(self, request, name):
>>        namestack = request.getTraversalStack()
>>        if name not in namestack:
>>            namestack.append(name)
>>        namestack.reverse()
>>        tags = tuple(namestack)
>>        request.setTraversalStack([])
>>        results = TaggedArticleFinder(self.__name__,self.__parent__,tags)
>>        results.prepareSearch(request)
>>        return results
>>The 'TaggedArticleFinder' then provides an interface that a view can
>>be found for that displays the results. So I've got it all working
> My coworker Albertas recently implemented something like this in
> SchoolTool (I've CCed him).  Unfortunately it turned out to have some
> unforeseen consequences, for example, request.URL does not contain the
> path elements you "eat" manually, breaking self-posting forms (those
> that use <form tal:attributes="action request/URL">) and our login
> mechanism.

How about this? It gives
some extra work, but it doesn't mess with the request and leaves
request.URL reflecting the entire "path".

from zope.interface import implements
from zope.publisher.interfaces import IPublishTraverse
from import BrowserView

class BrowserViewStopTraversal(BrowserView):
    def __init__(self, context, request):
        self.context = context
        self.request = request
        self.traverse_subpath = []

    def publishTraverse(self, request, name):
        return self

    def __call__(self):
        """Just for example"""
        return ("traverse_subpath = %s\nrequest.URL = %s" %
                (self.traverse_subpath, self.request.URL))


http://localhost:8080/@@stoptrav/foo/bar/baz  =>
  traverse_subpath = [u'foo', u'bar', u'baz']
  request.URL = http://localhost:8080/@@stoptrav/foo/bar/baz

-- Wade Leftwich
Ithaca, NY

Zope3-users mailing list

Reply via email to