[Grok-dev] Re: Neanderthal sprint topics

Philipp von Weitershausen philipp at weitershausen.de
Tue Oct 2 16:57:11 EDT 2007


Martijn Faassen wrote:
> Philipp von Weitershausen wrote:
>> On 2 Oct 2007, at 17:41 , Lennart Regebro wrote:
> [snip]
>>>> Genshi uses the "push" model for templates (the view code pushes the
>>>> data that the template needs into the template, rather than ZPTs
>>>> fetching the data they need). I very much like "push". In Grok we
>>>> typically have "semi-push" where the view class prepares data as
>>>> attributes of self in update() and the the template accesses it as
>>>> view.foo. So Genshi templates need to at least get the 'view' object,
>>>> and the 'request' probably too. Perhaps 'context'.
>>>
>>> So far so good. :-) We probably need to make the push story slightly 
>>> simpler.
>>> But basically, it works now, except of course, you don't have any path
>>> expressions, mening you can't find any other views an call them, and
>>> that would be useful.
>>
>> I don't think that's necessarily a bad thing. You're not really 
>> supposed to do too many fancy things in templates anyway. And you'll 
>> always have view.url() to compute URLs, so no need for @@absolute_url. 
>> Then we only need to make resources work, possibly also through a 
>> convenience method on the view or so. That should get most of the 
>> stuff covered.
> 
> 'static' doesn't work. That's a bad thing. :)

So, ok: context, request, view, static... That's what we should support :).

> In general, I don't think we should make this difficult deliberately.

Agreed. But, Grok also has had the tendency to push people in the right 
direction. By *carefully* doing this (not *annyoingly* obviously) we 
should be able to do this.

> We should push in a helper function that allows you to easily do this.
> 
> On it being a push model, we push the context, request and view to the 
> template. :)

Well, yeah. But you'd be surprised how many ZPT templates you see in 
Zope (2) applications (such as Plone) that abuse the availability of 
'context' and reach waaaaaay too much into content space. Admittedly 
it's a combination of having 'context', acquisition and Python 
expressions. But still. We should try to find a decent compromise.

> Genshi doesn't really require anything. It might be nice to 
> also *in addition* push in other things easily, though of course we 
> already have the update() method to set things up on the view.

Yup. I think we should focus on documenting the "semi-push" pattern by 
setting stuff on the view object in update(). People will always figure 
out that they can do much more in the template than they should actually 
be able to. In fact, Genshi makes it a bit easier because it has no ugly 
path expressions but actual Python expressions. It's actually also a 
reason why I think Genshi is nicer (things like tuple unpacking, 
iteration edge cases, etc. are ugly in ZPT).

ME GROK LIKE GENSHI.


-- 
http://worldcookery.com -- Professional Zope documentation and training


More information about the Grok-dev mailing list