Hi All,

After struggling using Python in classic ASP for quite a while, I have settled 
on a method to implement Python inside an existing project.

What I want to do is use an import() statement in a Python/PyScript code block 
in ASP to import a Python class, and in vbscript call some methods from that 
class.
The contents of the two simple files I used to test this is below. I get the 
following error:


Python ActiveX Scripting Engine error '80020009'

Traceback (most recent call last): File "<Script Block >", line 6, in <module> 
from pythonwsc import justtesting ImportError: cannot import name justtesting

/tools/erik/pytest.asp, line 8

from pythonwsc import justtesting


Can anyone explain why this gives me this error and if it is at all possible to 
call a Python method with a leading classname like justtesting.list_builtins() 
from vbscript ?
The thing is that I need the method (in this case list_builtins) with a leading 
class name (in this case justtesting) to be able to integrate Python in this 
project. I know it's possible to accomplish calling a Python function from 
vbscript -without- the classname, by importing the function directly, instead 
of the class, but that is no solution in my current situation.

If anyone has a suggestion, I'd be very grateful.

Thanks, kind regards,

Erik
--------------------- pytest.asp ---------------------

<script language="Python" runat="server">
import os
mod_path = Server.MapPath("./pythonwsc.py")
print "MOD", mod_path
import sys; sys.path.append(os.path.dirname(mod_path))
Response.write(os.path.dirname(mod_path))
from pythonwsc import justtesting
</script>

<script language="vbscript" runat="server">
 Response.write("<hr/>")
 Response.write(justtesting.list_builtins())
 Response.write("<hr/>")
</script>

--------------------- end pytest.asp ---------------------

--------------------- pythonwsc.py ---------------------

class justtesting:
 import win32traceutil
 import sys
 import os.path

 def __init__(self):
  pass

 def test(self):
  """Testing a simple function"""
  returnvalue = 'Simple test succeeded'
  return returnvalue

 def test_asp_objects(self):
  Response.Write("testing response.write")
  return Server.MapPath(".")

 def trigger_error(self):
  (x,y) = (5,0)
  z=x/y

 def list_builtins(self):
  """Small Python test, listing the builtin functions using the
  Python 'dir' command"""
  l = dir(__builtins__)
  strl = "<br/>".join(l) #dir returns a sorted list of strings, join into one 
big string with BR's inside
  return strl
--------------------- end pythonwsc.py ---------------------
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to