[Grok-dev] Grok's update/render pattern

Graham Stratton gns24 at mythic-beasts.com
Mon Jul 14 02:20:35 EDT 2008

Sorry to bring this up again, but it's causing me confusion.

Grok defines the way that the update/render pattern works differently  
from zope.contentprovider.  The contentprovider API states that the  
update method is used only to update the underlying objects based on  
the request, whereas the render method does everything to do with  

In grok, the update method is used to set attributes on the view to be  
used in templates, and would perhaps be better named 'prepare'. This  
is fundamentally different, and rather confusing. This is especially  
so for people using viewlets with grok, where the API inherits from  

This would be a real issue if the content provider API actually  
worked, which sadly it doesn't if you render content providers using  
the TAL provider: directive. I've been thinking about how to make  
proper use of the content provider API, but I think there would need  
to be some pretty fundamental changes somewhere. (In order to update  
every content provider without rendering any of them, you'd probably  
need to update every content provider registered for the current  
(context,request,view), regardless of whether it would actually be  
rendered, which might lead to *really* obscure bugs).

The motivation for zope.contentprovider's separate update/render  
process is that any page component may want to update the underlying  
objects based on a request, and any other page component might render  
differently depending on that update. If after every change to the  
application data a redirect is made, then this largely removes the  
problem, although it might be considered wasteful to render parts of  
the page when other parts are going to abandon the request with a  
redirect anyway. However, I think this is considered best practice at  
the moment. I'm not sure whether this would ever fail. I can probably  
construct a situation where a GET request would update a list of  
what's been viewed, in which case being able to utilise  
zope.contentprovider's API would be nice.

I have been a little sloppy here, as I'm mixing two issues:

- The difference between the two update/render APIs
- The inadequacy of the zope.contentprovider API with Zope as it is  
generally used

I'd be very interested to hear what other people are thinking about  
this. I've found viewlets to be very clean and useful, but this issue  
is making me feel uncomfortable with them, and certainly with trying  
to promote their use.

Many thanks,


More information about the Grok-dev mailing list