Help! IIS and Python

Jim Abrams jim at publishingresources.com
Tue Feb 26 22:12:21 CET 2002


"Steve Holden" <sholden at holdenweb.com> wrote in
news:ZtAa8.211294$KM2.8800436 at atlpnn01.usenetserver.com: 

> The problem here appears to be that you are probably getting a COM
> object of some sort back as a result of your call to
> Request.ServerVariables(), and when you try to apply the upper()
> function from the string module it complains that you  aren't apssing
> the right kind of object as an argument. 
> 
> If you replace
> 
>     server = Request.ServerVariables("SERVER_NAME")
> 
> with
> 
>     server = str(Request.ServerVariables("SERVER_NAME"))
> 
> for example, you will get a Python string back and all should be
> copacetic. 
> 
> I personally I find it so tiresome to interact with the Scripting
> environment in this way I have now moved away form IIS completely, and
> use Apache or Xitami as a web server. I recently had to go back to
> coding VBScript for IIS, and it was painful.

If, like me, you don't have the option of moving away from IIS, you can 
save yourself alot of headache, time, and resources by writing a nice 
wrapper object, sticking Response inside and using your own. You can then 
add sorely lacking functionality, like str conversion, to it as well as any 
additional shortcuts.

I do it for most of the built ins (Response, Request, Server, Appication, 
Session) and it's been a lifesaver.

Also (in reply to somewhere in this thread) you can do a quick:
from win32com.axscript.client.framework import SafeOutput
_out = SafeOutput(Response)

then use 
print >> _out, Stuff

to get the handy print str conversion. Which Response.Write doesn't do.
Don't use sys.stdout = etc and regular print.

In addition to HTMLgen, which is almost a requirement for Python in ASP, 
check out the string iterpolation module, it also has come it quite handy 
for me. Itpl.py

-Jim




More information about the Python-list mailing list