|
From: Samuele P. <ped...@bl...> - 2002-01-28 21:15:27
|
Hi. I'm not sure about what you are trying to achieve but
consider:
<frag.py>
A().describe()
</frag.py>
Then we assume that frag.py is jythonc-ed.
<run.py>
from java.lang import Class
# jythonc compiled frag should be classpath reachable
fragpy=Class.forName("frag$_PyInner")
class A:
def describe(self):
print "I'm an A instance coming from no-where"
frag_code = fragpy().getMain()
exec frag_code in { 'A': A }
</run.py>
I don't know if your applet is a java or jython applet. But if you want to
compile things -
as it seems - separately that point does not change things that much,
in the sense that run.py equivalent does not know that much about frag.py
anyway.
and so all the easy answers don't work <wink>.
If your applet is a java applet then you should consider doing the same
from java with Py.runCode(code,locals,globals), or PythonInterpreter.exec, ...
Btw, this is *highly* *undocumented* and *unsupported* (that means it works for
jython 2.0
and jython 2.1, dunno for jython 2.2).
regards, Samuele Pedroni.
----- Original Message -----
From: Sells, Fred <fr...@ad...>
To: <jyt...@so...>
Sent: Monday, January 28, 2002 7:28 PM
Subject: [Jython-users] jythonc, tricky class, cannot instantiate
> Attached is an example of a jython file that I use to define a form and the
> corresponding source that jythonc generates.
>
> I am using this in an applet and can "exec()" the file after loading up its
> namespace as needed.
>
> I would like to generate the class files and jar them to improve speed and
> avoid downloading the parser and opening the security restrictions for
> applets.
>
> I know that my file does not really look like a python class file and
> therefore I may be generating some funky java. The reason the python looks
> the way it does is to hid the fact from the form designer that they are
> programming.
>
> this error is generated by any reference to AA() or to AA.main(...)
>
> I use this to build the jar: jythonc --jar mds20form.jar --all *.py
>
> Exception occurred during event dispatching: java.lang.NoSuchMethodError
>
> at mds20form.AA.main(AA.java:140)
> at formspec.PageRepository.getSection(PageRepository.java:83)
> at mdsapplet.ControlMDSSections.selectPage(ControlMDSSections.java:91)
> at mdsapplet.ControlMDSSections.processCommand(ControlMDSSections.java:49)
>
> at gui.Dispatcher.run(ezActionManager.java:28)
> at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:317)
> at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
>
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
>
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
>
>
|