PythonWin ASP performance

Steve Holden sholden at holdenweb.com
Thu Oct 18 08:16:36 EDT 2001


"maxm" <maxmcorp at worldonline.dk> wrote in ...
>
> "Jim Abrams" <jim at publishingresources.com
>
> > Using Python makes life easier in so many ways I can't even begin to
> > describe them all, but some of the main ones are the object oriented
> > approach. (We've encapsulated the ASP Built-in objects with Python
> wrappers
> > that solve alot of VBscript ickiness, and are subclassable)
>
> I have tried Python asp, but found some ick-ines where the indenting
messes
> up the clarity of the asp page.
>
> in something like:
>
> <%for i in range(10):%>
>
> <font size="+1"><%= i%></font><br>
>
> I have to write:
>
> <%
> for i in range(10):
>     Response.Write('<font size="+1">' + i + '</font><br>')
> %>
>
> instead.
>
> In this simple example it isn't that bad, but when writing longer html,
> tables etc it sort of defeats the purpose of asp. Suddenly I get logic and
> presentation forced together.
>
> Have you got any good soultions to that?
>
The major solution is to build the HTML output as a list of strings, then
join them together in some appropriate way when it's time to send output.
E.g.:

    <%
    result = ["<h2>Sample Output</h2>"]
    for i in range(10):
        result.append("""<font size="+1">%d</font><br>""" % i)
    result = "\n".join(result)
    %>
<HTML>
...
<BODY>
<%=result%>
</BODY>

Unfortunately, or fortunately, depending how you look at it, ASP forces the
Python interpreter to treat each distinct code block as standalone, so you
can't terminate a code block halfway through and then restart code at the
same indentation level. "Icky" is right. But you can make it work, and many
have.

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list