[Grok-dev] Trails

Kevin Smith kevin at mcweekly.com
Fri May 2 15:09:02 EDT 2008

Brandon Craig Rhodes wrote:
> Kevin Smith <kevin at mcweekly.com> writes:
>> (Brandon I think I may have a few ideas to bounce of off you to
>> expand megrok.trials, email if you're interested)
> Yes!  I'd love to hear ideas.  If you'd like, please insult it and
> suggest improvements right here on the list in front of everyone, :-)
> so that as many ideas and perspectives as possible can be offered.
> Start a new thread with "Trails" in the name, though. :-)
(I suppose theirs no room for introverts in open source anymore)

I think megrok.trails is great,  my thoughts on a way of expanding it 
are along the lines of the following.

class MyTrails(megrok.trails.TrailHead):
    grok.name('mytrails') #default from class name

    # the trails attribute is left blank

class News(grok.View):
    grok.name('mytrails::/news') #signifys MyTrails as trail head and /news as child url

class Archive(grok.View):
    grok.name('mytrails::/news/archive') # another page

class Archives(grok.View):
    grok.name('mytrails::/news/archive/++subpath++') # stuffs remaining url parts
    # as signifyed by ++subpath++ into self.subpath Zope2 style

    def year(self):
	return self.subpath[-1]

    def month(self):
	return self.subpath[-2]

In my own code, I use grok.context(Traversable) instead of TrailStop, 
but I want to retain the metaphor here. There's lots of room for 
improvement, but I think you can get the drift.

It's pretty concise and easy to use. I've been using something similar 
successfully for over a year.

Kevin Smith

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20080502/9fab25be/attachment.html

More information about the Grok-dev mailing list