Help! IIS and Python

Steve Holden 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...
> Hello
> 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.
> thanks
> Sunit
> 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>
> <BODY>
> <p>
> <h3><font color="#990033">You are coming from <b><font
> color="#669900"><%=clientIP%></font></b>
> to <%=server%></font></h3>
>
> <hr>
> PythonAspTest
> </BODY>
> </HTML>
> 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")

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.

regards
 Steve
--
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 mailing list