Re: request.model in public layout

Andy Altepeter <[email protected]>
Newsgroups gmane.comp.web.zope.silva.devel
Organization Bethel University
Message-ID <[email protected]>
On Tuesday 04 April 2006 9:10 am, Roman Joost wrote:
> Hi Jan-Wijbrand,
>
> On Tue, Apr 04, 2006 at 01:17:38PM +0200, Jan-Wijbrand Kolman wrote:
> > This fix involves an explicit delete of the model from the request, when
> > the public layout is rendered. Having the model attached to the request
> > resulted in a cyclic reference of a type that could not be garbage
> > collected by Python.
> >
> > The default Silva public layout templates make no use of the model that
> > used to be available and having the model on the request for public
> > rendering was never intended to be a public API. In public renderings,
> > the content object being rendered is available through the 'context'
> > namespace.
>
> Maybe I just got it totally wrong here, but is the model deleted from the
> request *after* the view is rendered, or when does this happen?
>
> SilvaObject still adds the model to the request and I still run into
> problems if I try to render public views without providing the model as
> a request attribute.

I think what jw is saying is that 'model' will no longer be an attribute of 
REQUEST but of REQUEST.other (i.e. self.REQUEST.other['model'] = model).

further in jw's email:
> For the rare situations where you have developed code for the public 
> rendering of content that uses model.request (or model/request in a 
> pagetemplate) we now add the model to the request.other dictionary.

Because of REQUEST's getattr magic, request.model or request/model will still 
work.

What I don't understand, though, is why an explicit delete is required _only_ 
for the public layout?  Shouldn't the potential memory leak happen in other 
views as well?

Andy
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.