[Grok-dev] Re: A Django-like admin in Grok

Sebastian Ware sebastian at urbantalk.se
Fri Apr 25 02:07:20 EDT 2008


I had no idea! This is very cool, could you not add this as a side  
note in the upcoming viewlet docs. I don't know how else one would  
have stumbled upon it because I have never seen this mentioned in any  
TAL docs.

Mvh Sebastian

25 apr 2008 kl. 00.57 skrev Kevin Smith:
> from zope.traversing.interfaces import IPathAdapter
> from zope.tales.interfaces import ITALESFunctionNamespace
>
> class MyFilter(grok.Adapter):
>     grok.context(interface.Interface)
>     grok.implements(interface.Interface, ITALESFunctionNamespace,  
> IPathAdapter)
>     grok.provides(IPathAdapter)
>     grok.name('myfilter') # name to access 'filter'
>
>     def upper(self):
>        return self.context.upper()
>
>     def lower(self):
>        return self.context.lower()
>
>     def cap_words(self):
>        return ' '.join([x.capitalize() for x in self.context.split()])
>
>     def myadapter(self):
>        return IMyAdapter(self.context).myattribute
>
>
> used like:
> <span tal:replace="context/title/myfilter:upper" />



More information about the Grok-dev mailing list