Python and ASP question
Tom Funk
no_spam_tdfunk at nettally.com_spam_sux
Tue Feb 29 22:52:39 EST 2000
Yosef:
In an article posted Sun, 27 Feb 2000 09:06:47 GMT,
yosefgold at hotmail.com (yosefgold at hotmail.com) said:
> I am trying to import a module (using the 'import' statement) into an
> ASP page and it does not seem to be working. Is this a limitation of
> Python/ASP or am I doing something wrong?
There are a couple of things you might want to check:
That the Win32 Python Extensions are properly installed.
Your Python version is 1.5.2.
<%@Language=Python%> as the first executable line in the ASP file.
Between the <% %> delimiters, leading spaces are important. For instance:
<%
import sys
pyVersion = sys.version
%>
will work. Whereas
<%
import sys
pyVersion = sys.version
%>
will fail. The interpreter doesn't like the leading spaces in front of
import and pyVersion.
Here's a sample ASP file that should work as-is (it works for me). Copy
and paste it into an ASP file and execute it from your server. It should
display the current Python version and a list of server environment
variables.
If this doesn't work, your Win32 Extensions installation may be hosed up.
-----------[ copy after this line ]--------------
<%@Language=Python%>
<html>
<body>
<%
# NO leading spaces here
indent = " " * 5
def emitEnv():
# leading spaces needed here...
import os
for key in os.environ.keys():
Response.Write("<br>%s<b>%s</b>=%s\n" %
(indent, key, os.environ[key]))
# again, NO leading spaces here
import sys
pyVersion = sys.version
%>
<h3>Current Python Version</h3>
<p><%=indent + pyVersion%></p>
<h3>Server Environment Variables</h3>
<%
# no leading spaces, yet again
emitEnv()
%>
<body>
<html>
-----------[ copy before this line ]--------------
Hope this helps some.
Btw, it sometimes makes it easier to get assistance around here if you
include error messages and/or tracebacks when you have problems. "import
won't work" is a bit vague. Just a thought.... <g>
-=< tom >=-
Thomas D. Funk (tdfunk at asd-web.com) | "Software is the lever
Software Engineering Consultant | Archimedes was searching for"
Advanced Systems Design, Tallahassee FL. |
More information about the Python-list
mailing list