L. Daniel Burr ha scritto:
Hi Manlio,

On Thu, 04 Jan 2007 04:58:16 -0600, Manlio Perillo <[EMAIL PROTECTED]> 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?

Here is an example of "complex" template.
The form handling is done via a package I have written:


  <form method="post" action="./" accept-charset="utf-8"
        n:data="form_data">
    <div class="form_errors" n:render="form_errors" />

    <fieldset>
      <legend>Please, fill this</legend>

      <div n:data="somedate" n:render="form_control">
        <p class="label"><n:slot name="label" /></p>
        <input class="inline" type="text" size="2"
               n:data="somedate.day" n:render="form_value" /> /
        <input class="inline" type="text" size="2"
               n:data="somedate.month" n:render="form_value" /> /
        <input class="inline" type="text" size="4"
               n:data="somedate.year" n:render="form_value" />
        <p><n:slot name="help" /></p>
        <p class="required" n:render="form_required">
           The field is required
        </p>
      </div>

      <div n:data="x" n:render="form_control">
        <label for="x"><n:slot name="label" /></label>
        <select id="x" n:render="form_value">
          <option n:pattern="option" />
        </select>
        <p><n:slot name="help" /></p>
      </div>


The first form_data data directive push the form data into the context.

The form_control renderer fills the slot with label, and so.
The form_value renderer modifies the form control, setting the value attribute and so, depending on the type of control.

Without the use of data directives, that helps the renderer to locate the data, I can use only one renderer, attached to the <form> element.

Please note that I do not need all the IData stuff, I only need to now the tag.data value-

It should be possibile(?) to use only patterns and one renderer, I'll try to figure out how.





Regards  Manlio Perillo

_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

Reply via email to