[Zope3-Users] How come no IView?

Jeff Shell eucci.group at gmail.com
Sun Jan 1 22:40:58 EST 2006


> Thanks Chris, that actually does make things clearer. As a Z3 beginner,
> longtime Z2 user (ZPTs, scripts, ZSQL), and corporate developer who is
> trying to promote Z3 in-house, I am all for the current  trend toward
> simplification, especially of ZCML
> (http://www.z3lab.org/sections/blogs/philipp-weitershausen/2005_12_14_zcml-needs-to-do-less).
>
> It seems like "view class" is a useful concept that gets talked about a
> lot. We're not going to have to start saying "named multiadapter for
> content and request", are we?
>
> -- Wade

No. It's pretty much understood what a View is... Typically it means a
'browser view', but it could in fact be anything. FTP, a graphical
toolkit, and so on. The core component architecture doesn't tie
anything to the web.

But if you're looking for a base interface and class:

interface:
zope.app.publisher.interfaces.IBrowserView

class:
zope.app.publisher.BrowserView - has the __init__ with context and
request, and is also locatable (mapping __parent__ to the context).
This is a good one to subclass from, so if you need to do more work in
__init__ you can call BrowserView's to ensure that anything it might
do upon initialization in the future you get. But I doubt it will do
much more than set self.context and self.request.

While ZCML's view and page directives will put BrowserView into your
base classes automatically if it's not there, I prefer to still use it
as a base class directly. It makes the code more readable (I can see
that 'SearchResults' is a browser view immediately), and is just a
good concept (I believe) in making your code more Pythonic and less
dependent on you or other readers of it understanding the ZCML 'magic'
that goes on in the browser declarations.


More information about the Zope3-users mailing list