[Zope3-Users] Blog package

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Aug 17 10:46:49 EDT 2006


On Thursday 17 August 2006 10:32, David Pratt wrote:
> Hi Stephan. Yes, I have seen this added recently with great interest.
>
> :-) I'm hoping to experiment with this shortly to see how this works.
>
> Can you point to any code using this at the moment that I may see a
> practical demonstration of its integration. Many thanks.

Here is the basic idea:

  <!-- Make IBlog traversing pluggable for browser access only -->
  <view
      for=".interfaces.IBlog"
      type="zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.publisher.interfaces.browser.IBrowserPublisher"
      factory="z3c.traverser.browser.PluggableBrowserTraverser"
      permission="zope.Public"
      />

  <!-- Make sure container item traversal is available for all containers -->
  <subscriber
      for="zope.app.container.interfaces.IReadContainer
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="z3c.traverser.interfaces.ITraverserPlugin"
      factory="z3c.traverser.traverser.ContainerTraverserPlugin"
      />

  <!-- A plugin that traverses all years -->
  <subscriber
      for=".interfaces.IBlog
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="z3c.traverser.interfaces.ITraverserPlugin"
      factory=".blog.YearTraverser"
      />

In Python something like that:

import zope.interface
from zope.location import location
from zope.publisher.interfaces import NotFound
from z3c.traverser import interfaces

class YearTraverser(object):
    zope.interface.implements(interfaces.ITraverserPlugin)

    def __init__(self, context, request):
        self.context = context
        self.request = request

    def publishTraverse(self, request, name):
        yearNumber = int(name)
        if yearNumber < 2000:
            raise NotFound(name)
        year = YearProxy()
        location.locate(year, self.context, name)
        return tag

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-users mailing list