durusmail: quixote-users: New syntax for PTL templates?
New syntax for PTL templates?
2002-10-08
2002-10-08
2002-10-08
2002-10-08
2002-10-09
2002-10-09
2002-10-09
2002-10-09
2002-10-10
PTL for SQL (was Re: [Quixote-users] New syntax for PTL templates?)
2002-10-10
python 2.2 required for widgets
2002-10-28
2002-10-28
2002-10-28
2002-10-28
quote keyword on widget constructors
2002-10-29
2002-10-29
2002-10-29
2002-10-28
2002-10-28
2002-10-29
2002-10-29
2002-10-29
2002-10-10
New syntax for PTL templates?
Neil Schemenauer
2002-10-10
On Thu, Oct 10, 2002 at 09:27:20AM -0400, Joel Shprentz wrote:
> I hope that plain and html are class names, not keywords.

In the current implementation those names are part of the syntax not
identifiers.

> Then we would not be limited to three types of functions.  For
> example, one could imagine an sql class that converts strings to the
> appropriate form for SQL queries.
>
>     def bar [sql] (lastName):
>         "SELECT * FROM staff\n"
>         "WHERE last = "
>         lastName

How imaginary is this use case?  Would you or anyone you know use it?  I
would think it would be much better to use '?' parameters.  Eg.

         cursor.execute("SELECT * FROM staff "
                        "WHERE last = ?", lastName)

> The PTL documentation says, "the value is converted to a string using str()
> and appended to the template's return value. There's a single exception to
> this rule: None is the only value that's ever ignored, adding nothing to
> the output."
>
> I haven't looked under the hood to see where this is implemented.  Is it
> specific to the current string output, or is it generic to all PTL template
> processing?
>
> In the sql example, it would be better to convert None to SQL's NULL.  (But
> what about function calls that return None by default?  Hmmm.)  Also, sql
> could convert date class values to some date format recognized by SQL.

I'm not convinced that PTL is the right tool for that.  You could, for
example, right a cursor subclass that turned None into NULL.  I think
some or all Python DB interfaces do that already (it's been I while
since I used that stuff, thank god).

  Neil


reply