[Twisted-web] [Nevow] again on data directive

L. Daniel Burr ldanielburr at mac.com
Thu Jan 4 08:15:14 CST 2007

Hi Manlio,

On Thu, 04 Jan 2007 04:58:16 -0600, Manlio Perillo  
<manlio_perillo at libero.it> wrote:

> To put it simple, I would like to have this feature:
> <div n:data="xxx" n:render="yyy" />
> def render_yyy(request, tag):
>     assert tag.data == 'xxx'
> That is: data directives are only used to pass data from the template to  
> the renderer.
> Is this a good idea?

I think it is a bad idea, because it encourages what is, in my opinion, a
bad practice: You shouldn't be passing data from the template to the
renderer.  Data should reside in a model class, not within the attributes
of a template.  The view class should already have access to an instance
of the model, via self.original.

Why do you want to pass data directly from the template to the renderer?
I'm not sure why you want to violate the boundaries in this way, other
than some notion of convenience.  I readily agree that using a Nevow
template can sometimes be less convenient than some other templates,
which allow you to mingle data, logic, and rendering all in one place.
Going this route will lead to a big mess, in my opinion, and if you
want this kind of convenience, there is always PHP ;)

> Now what I can do is:
> <div data="xxx" n:render="yyy" />
> def render-yyy(request, tag):
>     assert tag.attributes.pop('data') == 'xxx'

Again, you seem to want to eliminate the need for a model class, and
I think that is short-sighted, at least from a code maintenance POV.

> Thanks and regards  Manlio Perillo

Hope this helps,

L. Daniel Burr

More information about the Twisted-web mailing list