[Zope3-Users] Blog package
David Pratt
fairwinds at eastlink.ca
Thu Aug 17 10:58:39 EDT 2006
Hi Stephan. Many thanks for this excellent example! :-)
Regards,
David
Stephan Richter wrote:
> 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
More information about the Zope3-users
mailing list