At 10:41 AM 10/10/02, Neil Schemenauer wrote:
>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)
For me, this use case is totally imaginary. I will not use it.
When using the Python DB API, your approach is great for canned queries. I
think the template based approach could be useful for more complex,
dynamically built queries.
For example, when I was shopping online for a new clothes dryer, I had to
answer questions like preferred brand, gas or electric, and maximum
price. This template could construct the query from those answers:
def searchDryers (brand, power, maxPrice):
"SELECT * FROM product WHERE type = 'dryer'"
if brand:
" AND brand = "
brand
if power:
" AND power = "
power
if maxPrice:
" AND price <= "
maxPrice
I introduced the sql example to suggest that your proposed improvement to
PTL has applicability beyond HTML. Others have mentioned XML. We still
use SGML. The quoting rules vary somewhat.
--
Joel Shprentz (703) 478-9668
1516 Park Glen Court jshprentz@his.com
Reston, VA 20190