Help! IIS and Python
sholden at holdenweb.com
Wed Feb 13 22:00:50 CET 2002
"Sunit Joshi" <sjoshi at ingr.com> wrote in message
news:8f8ffe67.0202131245.375fe55d at posting.google.com...
> I'm trying to use IIS5.0 with Python 2.1 and whenever I try to import
> modules I get an error. The test.asp and error are below.
> sjoshi at ingr.com
> <%@ Language=Python %>
> import string
> server = Request.ServerVariables("SERVER_NAME")
> server = string.upper(server)
> clientIP = Request.ServerVariables("REMOTE_ADDR")
> <HTML><HEAD><TITLE>Python Test Page</TITLE></HEAD>
> <h3><font color="#990033">You are coming from <b><font
> to <%=server%></font></h3>
> Error Type:
> Python ActiveX Scripting Engine (0x80020009)
> Traceback (innermost last): File "<Script Block >", line 3, in ?
> server = string.upper(server) File "C:\Python21\lib\string.py", line
> 60, in upper return s.upper() File
> "C:\Python21\win32com\client\dynamic.py", line 438, in __getattr__
> raise AttributeError, "%s.%s" % (self._username_, attr)
> AttributeError: <unknown>.upper
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")
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.
Consulting, training, speaking: http://www.holdenweb.com/
Author, Python Web Programming: http://pydish.holdenweb.com/pwp/
"This is Python. We don't care much about theory, except where it
intersects with useful practice." Aahz Maruch on c.l.py
More information about the Python-list