ADO/ODBC/ASP/Python error

maxm maxm at mxm.dk
Thu Jan 10 09:51:51 EST 2002


"Mark Ainsworth" <marka at sundance.com> wrote

> <%
> while not objRS.EOF:
>   Response.Write("<tr>")
>   for Head in headings:
>     Response.Write("<td>")
>     if Head == "Description":
>       """
>       If we are in the description section then we have to
>       create a link with the right values to the certificate
>       display page.
>       """
>       Response.Write("<a href=""certificate.asp?type=")
>       Response.Write(objRS("Reference"))
>       Response.Write(' >')
>     Response.Write(objRS(Head))
>     if Head == "Description":
>       Response.Write("</a>")
>     Response.Write("</td>")
>   Response.Write("</tr>")
>   objRS.Move(1)
> %>

Just a small optimisation tip. Putting the result into a list and then
joining it with an empty string is _much_ faster than sucessive
Response.Write's.

regards Max M

<%
result = []
a = result.append

while not objRS.EOF:
  a("<tr>")
  for Head in headings:
    a("<td>")
    if Head == "Description":
      """
      If we are in the description section then we have to
      create a link with the right values to the certificate
      display page.
      """
      a("<a href=""certificate.asp?type=")
      a(objRS("Reference"))
      a(' >')
    a(objRS(Head))
    if Head == "Description":
      a("</a>")
    a("</td>")
  a("</tr>")
  objRS.Move(1)
Response.Write(''.join(result))
%>






More information about the Python-list mailing list