Python, ASP - Namespace (again) 
Author Message
 Python, ASP - Namespace (again)

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
=================

<%
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



Sat, 15 Dec 2001 03:00:00 GMT  
 Python, ASP - Namespace (again)

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
=================

<%
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



Sat, 15 Dec 2001 03:00:00 GMT  
 Python, ASP - Namespace (again)
...

Quote:
>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 ?

There is no obvious reason to me why this wont work.  Note that if you are
not running win32all-125, then I recommend you upgrade - there have been
some fixes (but none that adddress this, as far as I can tell).

The best I can suggest is that you use the win32trace module and print
statements to work out what the hell is going on.

Eg, making your first line "import win32traceutil" will mean that all print
statement go to a debugging collector.  You can view the print statements by
starting Pythonwin on the same machine, and selecting "Tools/Trace Collector
Debugging Output".

Then use lots of print statements - specifically print dir() etc, to see
exactly what the namespace is...

Mark.



Sun, 16 Dec 2001 03:00:00 GMT  
 Python, ASP - Namespace (again)

...

Quote:
>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 ?

There is no obvious reason to me why this wont work.  Note that if you are
not running win32all-125, then I recommend you upgrade - there have been
some fixes (but none that adddress this, as far as I can tell).

The best I can suggest is that you use the win32trace module and print
statements to work out what the hell is going on.

Eg, making your first line "import win32traceutil" will mean that all print
statement go to a debugging collector.  You can view the print statements by
starting Pythonwin on the same machine, and selecting "Tools/Trace Collector
Debugging Output".

Then use lots of print statements - specifically print dir() etc, to see
exactly what the namespace is...

Mark.



Sun, 16 Dec 2001 03:00:00 GMT  
 Python, ASP - Namespace (again)
On Wed, 30 Jun 1999 09:00:20 +1000, "Mark Hammond"

Quote:

>There is no obvious reason to me why this wont work.  Note that if you are
>not running win32all-125, then I recommend you upgrade - there have been
>some fixes (but none that adddress this, as far as I can tell).

>The best I can suggest is that you use the win32trace module and print
>statements to work out what the hell is going on.

>Eg, making your first line "import win32traceutil" will mean that all print
>statement go to a debugging collector.  You can view the print statements by
>starting Pythonwin on the same machine, and selecting "Tools/Trace Collector
>Debugging Output".

>Then use lots of print statements - specifically print dir() etc, to see
>exactly what the namespace is...

>Mark.

Mark, thanks for hint on using the trace utility.

The next time I checked the code written in my first message, it
worked ok !!!!

As I indicated in the message, I have one ASP file and two PY files.
Updating the ASP file (saving it) followed by a refresh in the browser
results in updated browser page content.  However, updating any of the
PY files does not result in any changes in the browser output.  Could
anyone answer when the PY modules are loaded.  I thought the PY
modules automatically are reloaded if the datestamp of the *.py file
is newer than the *.pyc file.

I'm using the statement:

from <module> import *

How (if possible) would I reload explicitly such a module ?

Nikolai



Mon, 17 Dec 2001 03:00:00 GMT  
 Python, ASP - Namespace (again)

On Wed, 30 Jun 1999 09:00:20 +1000, "Mark Hammond"

Quote:

>There is no obvious reason to me why this wont work.  Note that if you are
>not running win32all-125, then I recommend you upgrade - there have been
>some fixes (but none that adddress this, as far as I can tell).

>The best I can suggest is that you use the win32trace module and print
>statements to work out what the hell is going on.

>Eg, making your first line "import win32traceutil" will mean that all print
>statement go to a debugging collector.  You can view the print statements by
>starting Pythonwin on the same machine, and selecting "Tools/Trace Collector
>Debugging Output".

>Then use lots of print statements - specifically print dir() etc, to see
>exactly what the namespace is...

>Mark.

Mark, thanks for hint on using the trace utility.

The next time I checked the code written in my first message, it
worked ok !!!!

As I indicated in the message, I have one ASP file and two PY files.
Updating the ASP file (saving it) followed by a refresh in the browser
results in updated browser page content.  However, updating any of the
PY files does not result in any changes in the browser output.  Could
anyone answer when the PY modules are loaded.  I thought the PY
modules automatically are reloaded if the datestamp of the *.py file
is newer than the *.pyc file.

I'm using the statement:

from <module> import *

How (if possible) would I reload explicitly such a module ?

Nikolai



Mon, 17 Dec 2001 03:00:00 GMT  
 Python, ASP - Namespace (again)

Quote:

>The next time I checked the code written in my first message, it
>worked ok !!!!

>As I indicated in the message, I have one ASP file and two PY files.
>Updating the ASP file (saving it) followed by a refresh in the browser
>results in updated browser page content.  However, updating any of the
>PY files does not result in any changes in the browser output.  Could
>anyone answer when the PY modules are loaded.  I thought the PY
>modules automatically are reloaded if the datestamp of the *.py file
>is newer than the *.pyc file.

IIS does the same thing with include files, i.e. only when the .asp
timestamp changes it is reprocessed, the same thing happens with
python. If the code is inside the .asp it works fine, if the code is
outside (i.e. in a .py) you have to touch the .asp so it gets
reprocessed.

Quote:
>I'm using the statement:

>from <module> import *

>How (if possible) would I reload explicitly such a module ?

Touching the .asp.


Fri, 21 Dec 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Python + IIS/ASP questions (modules, namespaces, etc)

2. ASP Namespace question

3. ASP and namespace

4. ASP templates again

5. Scheme vs ML again and again and again and again

6. Scheme vs ML again and again and again and again

7. ASP and ADO AGAIN!

8. Python 2.2 + Win32All 146 = Python/ASP Failures

9. Unicode + SuperUltraAllNewGetItNow Python Upgrade questions: ASP/VBScript->Python

10. SV ASP vs Fenix ASP

11. .asp or .inc for include files in ASP

12. Rexx and ASP/ASP.NET

 

 
Powered by phpBB® Forum Software