From: dman <ds...@ri...> - 2001-11-01 23:45:10
|
Hi all. This probably isn't appropriate for the -dev list, but too frequently I don't get a response on the -users list. I'm trying to use Jython(c) to allow using Moshe Zadka's PMS framework along with a Java/Swing GUI for a school project. (The other group members are writing the gui and they don't know python) I've run into a couple of problems, though, all related to java's type system. There are several modules in the PMS package. I have taken the base classes of the inheritance tree and made them inherit from java.lang.Object and added the @sig lines. A simplified example : ----- PMS/AbstractFolder.py class AbstractFolder( java.lang.Object ) : pass ----- PMS/Folder.py import AbstractFolder class Folder( AbstractFolder.AbstractFolder ) : pass I also have the following class as a factory for the GUI to create a hardcoded folder for the prototype demo. ----- DemoFolder1.py class DemoFolder1( java.lang.Object ) : def make( self , name ) : """ @sig public Object make( String name ) """ server = PMS.MaildirServer.MaildirServer( "server_name" , "." ) PMS.Configuration.Configuration().servers[ server ] = lambda x : x folder = PMS.Folder.Folder( server , name ) folder.create() print folder.__class__ # correctly prints "PMS.Folder.Folder" return folder I used jythonc to compile the stuff, and everything compiles fine. The Java code that uses this looks like : Object folder = (new DemoFolder1()).make( "Demo1" ); MailMessage.Message message = new MailMessage.Message(); // This line prints out // org.python.proxies.PMS.Folder$Folder$2 System.out.println( folder.getClass() ) ; try { ((Folder)folder).save_message( message ); } catch ( Exception err ) { // I get a ClassCastException here } Even though the Python factory returns an object that should match the generated java class, it doesn't match and java can't handle it. I also tried : Folder f = new Folder( new MaildirServer( "name" , "." ) , "Demo2" ) ; f.save_message( message ) ; This works if I write it in Python, but written in Java gives : Exception occurred during event dispatching: Traceback (innermost last): (no code object) at line 0 TypeError: __init__() takes at least 3 arguments (1 given) As you can see, too much debugging info was lost in the translation to java so I have no idea where this error is occurring. I can think of 2 workarounds to the problem, but neither is very desirable, so any suggestions, hints, pointers, or even wild guesses are greatly appreciated. As an additional annoyance, it seems that a jythonc-compiled python module can't import any python modules that are not translated to java. Is this limitation real, or am I just doing something wrong? TIA! -D |