Python, ASP - Namespace (again)

Nikolai Kirsebom nikolai at micon.no
Tue Jun 29 14:15:42 EDT 1999


Trying again - since I'm rather stuck, and I would like to stick to Python.


I'm trying to use Python as scripting language on the web-server, however -
have problems to see how the namespace scope is handled.

FILE - GenDb.py
=============
class GenDb:
   def __init__(self):
      self.ConnStr = ""

   def SetDbAndTable(self, db, table):
      self.Db = db
      self.Table = table
      self.ConnStr = "Driver={Microsoft Access Driver (*.mdb)};
DBQ=f:\\Databases\\%s" % db

   def Attr(self, attrName):
      if attrName == "abc":
         return(self.ConnStr)
      else:
         return("-non-")

FILE - KSdebatt.py
===============
from GenDb import *

class KSdebatt(GenDb):
   def __init__(self):
      self.SetDbAndTable("KSdebatt.mdb", "BillMrk")

FILE - SCRIPT1.ASP
=================
<%@ LANGUAGE = Python %>
<%
import sys
sys.path.append("f:\\PythonScripts")
from KSdebatt import *
o=KSdebatt()
%>
<HTML>
<INPUT TYPE="text" NAME="abc" VALUE="<%= o.Attr("abc") %>" SIZE=20>
</HTML>


when I run the statements in the script1.asp file in an interactive window,
I can create the KSdebatt object, however when I run the script on the
server - I  get the following message:

Python ActiveX Scripting Engine error '80020009'
Traceback (innermost last): File "<Script Block >", line 4, in ?
o=KSdebatt() NameError: KSdebatt
/ksdebatt/pages/Script1.asp, line 6
o=KSdebatt()

If it is possible I would like to 'hide' the object (o) inside the KSdebatt
module - that is to have the instanciation inside the module itself - but
still be able to access it from the ASP-code in the script (o.Attr....).  Is
this possible ?


I'm running on NT 4.0 SP 3 and python 1.5.2b2


Thanks for any help

Nikolai Kirsebom








More information about the Python-list mailing list