On 6/19/07, Mehendran T <TMehendran@...> wrote:
> I am going to write a new test module. I browsed the jython site.
> I got some tips. But that is not sufficient. I have some doubts.
What do you mean by test module? A test to see how to write a module
in Java, or a module to do testing? I'm only asking to see why you
want to write it in Java. If possible, it's easier to write things in
> 1. What is POJO object API? pls explain.
POJO stands for Plain Old Java Object. In the context of Jython it
means to write a regular class with the functions and data structures
you want to use from Python but without any explicit reference to
PyObject or any of the rest of the Jython runtime. This means it can
be used from places other than Jython without modification, but
prohibits you from doing some of the more Pythonic things that are
only accessible from methods on PyObject.
> 2. If I extend PyObject, what is the procedure?
I'm afraid there isn't a clear, blessed procedure for this at the
moment. There are several ways to go about it which we're going to
try to unify in the release past 2.2. The classic way is to just
extend PyObject and add the methods and fields you're interested in
directly to your subclass. Jython will reflect on the class at
runtime and expose the things you've added, and you can override the
Python methods on PyObject to customize things like __getitem__ or
__add__ and so on.
> 3. What about newstyle classes? Where is it used? How should I use in my module?
> Then tell me something about gexpose.py. is it necessary? why?
This is another way to make Python classes in Java. gexpose.py uses
an expose file per class which describes the methods and fields
accessible from that class. When run on that file, gexpose generates
an inner class per method or field and inserts that into the newstyle
class Java file. It's a way to generate all of the boilerplate
necessary to use descriptors and set up the class dict explicitly from
It's probably worth hearing what you're trying to do before getting
too deeply into this though.