On Monday 11 November 2002 20:26, brian zimmer wrote:
> I'm on board with the custom wrapping though I have a different suggest=
> In the past I made the static method Py.java2py(Object) delegate to a
> custom handler (the default being the current if/else statements in
> Py.java2py) to decide how to wrap a Java instance. I controlled which
> handler by checking an option in the jython registry. I don't have the
Did you use a __javawrapper__ from the registry instead of from the curre=
namespace? That would be hardly different.
> code any more but I can code it up again and submit a patch if you or
> anyone else is interested in seeing my idea.
I don't have a direct interest other than that I think that the current=20
implementation is confusing about where the borders are between python an=
java (eg. a java.util.Hashtable can be indexed using square brackets) and=
that I'd like these things to be more explicit.
Also I'd prefer to have such behaviour coded in python code where possibl=
> > So basically, you want to add some behaviour to java objects used on =
> > python side. For that you will indeed need some support from jython.
> > How about opening your script with:
> > __javawrapper__ =3D yourWrappingClass
> > ?
> > yourWrappingClass is a python class that would be automatically
> > instantiated
> > as a wrapper for every java object created. A java flagging
> > interface would
> > not even needed.
> > In case __javawrapper__ is not instantiated, the java wrapping behavi=
> > would default to the current behaviour.
> > In principle, this also allows to remove the current behaviour
> > from java and
> > move it into eg. a built in __defaultjavawrapper__.
> > You could than also extend the default wrapper:
> > class yourWrappingClass(__defaultjavawrapper__):
> > " define even nicer tricks using the default tricks "
> > ...
> > It looks and feels pythonic enough to me.
> > Any thoughts?