PythonWin ASP performance

Jim Abrams jim at
Thu Oct 18 23:51:43 CEST 2001

"maxm" <maxmcorp at> wrote in
<Uxmz7.2652$5v1.259860 at>: 

>"Jim Abrams" <jim at
>> 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>')
>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?
>regards Max M

I agree, pretty icky. 
There's alot of approaches to solve this issue (as mentioned by other posters), but 
here's what I do, and it seems to work pretty well. (Without investing into some type of 
content vs. presentation packages)

If its a fairly simple block of HTML, put it inside a triple-quotes string and then use 
%-subs for data.

print >> _out, '''
          <td> </td>
          <td class="regular" width="50%%">
            <a href="email/email.asp?fmt=ppt&file=%s">Email this %s</a>
''' % (enc(path), f_type)

But you have to watch out for the regular %'s throwing you off.

Or, (and this is the method I find most useful), there is the HTMLgen package.
Simply put, it takes all the HTML tags and converts them into Python classes.
Makes life easier.

		print >> _out, TR(TD(
				TD(Bold(objRS.prev_link(me2), html_escape='off')),
				TD(" :: "),
				TD(Bold(objRS.next_link(me2), html_escape='off'))

You get the idea. 

><%for i in range(10):%>
><font size="+1"><%= i%></font><br>


>for i in range(10):
>    print >> _out, Font(i, size='+1'), BR()

More information about the Python-list mailing list