[Zope3-dev] Re: [Zope3-dev]
Re: Zope3/src/zope/app/browser/skins/debug/exceptions.py:1.1
Tres Seaver
tseaver@zope.com
12 Mar 2003 11:10:14 -0500
On Wed, 2003-03-12 at 10:57, Steve Alexander wrote:
>
> > Actually, I'm not worried about *when* the work gets done; I'm worried
> > about *by whom*. A component user who wants to customize the display of
> > the traceback will have a much harder time doing so if the component
> > hard-wires its presentation by calling a black-box Python method.
>
> Are you saying that you'd prefer to design the view for customisation by
> subclassing, and perhaps have a formatTraceback(tb) method that could be
> easily overridden?
I want the customization to occur in the template, not in Python.
> > This particular case is tricky, because we *don't* want to keep the
> > actual traceback object around for any length of time.
>
> It should only be kept around for the duration of the request. Your try:
> finally: should ensure circular references are broken.
Right. Note that the 'traceback_lines' don't encode any knowledge of a
particular rendering form: this view class should work as a base both
for the "show the developer the traceback" page, and for the
hypothetical "generate a mail to the site manager" template.
> I feel like I'm missing your point... :-/ If it looks that way, please
> put me right.
My main point is that I *don't* want to emit HTML from within a Python
function: that is what templates are for. The current implementation
computes a data structure from the traceback, but leaves its
HTML-ification to the template. This way, when I get lambasted for how
ugly the rendered output is, I can reply, "Customize the template".
> > FWIW, in other work, I do find it a pattern that I will do lots of
> > adapter lookup in the __init__ of the view class, in order to make the
> > adapted content object easily available to the template.
>
> That could make certain things unnecessarily slow.
> In this case, it would be better to look up the adapters in the method
> that gets called before a template is rendered. (Which doesn't yet exist.)
I don't imagine that optimizing the "view gets created but not rendered"
case is huge win for the majority of "application"-level views; I am
glad to be shown wrong, however. :)
Tres.
--
===============================================================
Tres Seaver tseaver@zope.com
Zope Corporation "Zope Dealers" http://www.zope.com