[Grok-dev] Traversing over attributes/methods in grok.View
sebastian at urbantalk.se
Wed Sep 15 04:20:50 EDT 2010
You could use:
def publishTraverse(self, request, name):
# do your stuff and call your methods here...
13 sep 2010 kl. 14.31 skrev Jasper Spaans:
> On Mon, Sep 13, 2010 at 01:58:23PM +0200, Christian Klinger wrote:
>> i try to access attributes/methods of a grok.View via traversal.
>> But i have no idea where to look for a solution.
>> Take a look at this exmaple: I think it shows what i want...
>> class MyView(grok.View):
>> def foo(self):
>> return "foo"
>> def render(self):
>> return "normal view"
>> "normal view"
>> Any idea how i can do this? I guess i have to look in zope.publication
>> and or zope.traversal.
> The closest you can get probably is grok.traversable:
> but than will need you to have methods which are defined on your Model
> class instead of on your view.
> You can than add an adapter for string-like objects, which returns the
> things as-is, like
> class MyStringViewer(grok.View)
> def render(self):
> return self.context
> [*] completely untested code here, but it might work.
> Ir. Jasper Spaans http://jasper.es/
> 14:28:23 up 12262 days, 5:15, 1 user, load average: 0.00 0.00 0.00
> emacs... car rater vi, c'est un droit inaliénable
> Grok-dev mailing list
> Grok-dev at zope.org
More information about the Grok-dev