[Zope3-Users] Re: How to make content object return a view?

Philipp von Weitershausen philipp at weitershausen.de
Fri May 26 06:21:42 EDT 2006


David Johnson wrote:
> I have a content object, that I want to return a view.  How is this
> done?

It usually isn't.

> This situation seems to come up frequently for me.  What do you
> do?

Content objects are usually dull. The only thing they do is store data.
If you're using ZODB persistency, then a content object can be two lines
of code:

class MyContent(persistent.Persistent):
    pass

In particular, content objects often have no methods and they definitely
don't deal with the request. This is left to views. So, somethign in
your app needs to deal with a request, write a view.

> In this case, the content object is a fax.  The fax will include browser
> views as part of it's body.

That seems like a backward approach. The fax body will probably be
rendered using other views. The body rendering view should pull in other
views. Not the fax object itself.

> I tried zapi.getView(), but this has been deprecated, and I don't quite
> understand the best approach.

Don't mix storage and presentation :).

Philipp



More information about the Zope3-users mailing list