durusmail: quixote-users: PTL and strings
PTL and strings
2004-05-10
2004-05-10
2004-05-11
2004-05-10
PTL and strings
Neil Schemenauer
2004-05-10
On Mon, May 10, 2004 at 12:55:21PM -0700, vincent delft wrote:
> OK. my example is quite stupid.
> But on the core of the problem; do you agreed ?

I agree that it is annoying that htmltext instances cannot be used
everywhere a string can be used.  However, I don't think it's
possible for the PTL compiler to determine where you really want a
string literal rather than a htmltext literal.

> When I write an html related text, I know what I'm
> doing.
> When I'm writing python code, I must always think
> about "Am I in a ptl file or py file ?".
>
> I'm maybe the only one, but it's disturbing.
>
> Is there a way to avoid this ?

We now use the .ptl extension for all UI modules.  The question then
becomes "Am I in a [html] template or not?".  You can have normal
functions inside .ptl files.

> I think of:
> - using regexp (or other tool) to identify html
> related lines.
>
> - asking developers to identify the html related lines
> by using a function (does not matter the name). This
> is probably the most simple method, but it's not
> backward compatible and will disturb current habits.

i suggest making a helper function.  Factoring things out into
helper functions almost always works for us and has the nice side
effect of producing more maintainable code.

  Neil


reply