On 4/5/06, Ian Bicking <[EMAIL PROTECTED]> wrote:

> I think it's fine in some ways.  It has some Rubyisms, like using
> dictionaries where keyword arguments would do.  Ruby doesn't have
> keyword arguments; we should pity them, not emulate them ;)

In this special case, using a dictionary is safer and cleaner IMO.
See the klass or class_ problem for example.

> The line ending changes seem unnecessary; Python handles that at
> different places in the stack.  __add__ and __sub__ definitely shouldn't
> have side effects (__iadd__ and __isub__ can, though).

The line endings will be used in the generated html. Thus, if you want
a Windows generated html to be integrated in your Windows template,
you can avoid line endings incompatibilities.

> _called
> shouldn't be an instance variable; it should really be an argument
> somewhere.

Thanks, I'll investigate that.

> __slots__ is an unnecessary optimization.

I didn't know that ? Do you have any pointer about this ?

  __call__ can both
> update items in-place and create new tags, and not inherit all
> attributes during the copy.  And it doesn't know about HTML tags that
> can't be collapsed, like <script></script> shouldn't be spelled <script/>

This is not a problem. If you need an empty uncollapsed tag (example:
textarea), just pass it an empty string as value. Having to maintain a
list of uncollapsable tags is boring and restrictive.

> I agree that klass is not a very good convention; class_ is better to
> use than klass.  It's even PEP-8-certified ;)

Both look hackish to me :/

> .open() and .close() can be quite nice when building, for example, a
> select list:
>
>    select = html.select.open()
>    for item, desc in items:
>        select.option(value=item)(desc)
>    select.close()
>
> Which is nicer (IMHO) than:
>
>    options = []
>    for item, desc in items:
>        options.append(html.option(value=item)(desc))
>    select = html.select(options)
>
> Often things become inverted with the second form, where you build lists
> and only later show what you are building them for.  I think py.xml
> would use this pattern (vaguely; not sure about the exact syntax):
>
>    select = html.select()
>    for item, desc in items:
>        select.append(html.option(value=item)(desc))
>
> This might be the simplest and most clear way.

Yes, the last one probably looks better. At the moment, it can easily
be done in my class with:

html.select( *[html.option({'value':i})(items[i]) for i in items] )

But I admit it's maybe not as readable.

If one need to open and close tags, then why not just write plain html
directly...
I understand it's a feature, but I think there should only one way to
do it with such little utility objects.

Thanks for your comments, I'll look at your suggestion.

----
Bertrand Mansion
Mamasam

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss
-~----------~----~----~----~------~----~------~--~---

Reply via email to