From: Krajnak, M. (MED) <mic...@me...> - 2001-08-24 21:26:26
|
Summary: When I split my classes into multiple files the JythonServlet reports a type error and can't find the extra classes. Details: I've set up and run the JythonServlet on my Win2K box and created some sample servlets. I'm using Jython 2.1a3. I have jython in D:\opt\jython and my servlet context for Tomcat is at D:\dev\jyserv. The jyserv directory looks like this: \jyserv \WEB-INF \classes \lib jython.jar \jython \sample test1.py And test1.py is: --- jyserv/sample/test1.py: import sys from javax.servlet.http import HttpServlet class message: def __init__(self, pMsg): self.msg = pMsg def getMessage(self): return self.msg class test1(HttpServlet): def doGet(self, request, response): response.setContentType("text/html") out = response.getOutputStream() self.mesg = message("Hi Bob!") out.println(self.mesg.getMessage()) out.close() return ---eof Running jython servlet in Tomcat and going to http://localhost:8080/jyserv/sample/test1.py Displays the "Hi Bob!" message as expected. If I split the files into two like so: --- jyserv\sample\message.py: class message: def __init__(self, pMsg): self.msg = pMsg def getMessage(self): return self.msg ---eof --- jyserv\sample\test1.py: import sys from javax.servlet.http import HttpServlet class test1(HttpServlet): def doGet(self, request, response): response.setContentType("text/html") out = response.getOutputStream() self.mesg = message("Hi Bob!") out.println(self.mesg.getMessage()) out.close() return ---eof And after restarting Tomcat I get a type error: Traceback (innermost last): File "D:\dev\jythonservlet\worklist\test.py", line 9, in doGet TypeError: call of non-function (module 'message') I've tried various forms of import and from. I've inspected python path to make sure \dev\jyserv was in the path. I'm fairly new to Python. Has anyone else had this problem? Why can't I split up my classes into different files? Thanks!! Mike |