What is the RIGHT way to patch python modules for jython?

Steve Cohen cohsteve at attbi.com
Mon Jan 7 21:25:57 EST 2002


Thanks for the information.

Martin von Loewis wrote:

> Steve Cohen <cohsteve at attbi.com> writes:
> 
> 
>>1)  What is the RIGHT way to patch python modules to allow special hooks 
>>needed for jython?  I assume the import statements must be within 
>>conditionals, right?  
>>
> 
> Right. It would be even more desirable if you can find changes that
> make cmd work out of the box, such as introducing a readline module in
> Jython.


There IS (now, as of Jython 2.1) a readline module in jython. 
Interfacing it to cmd is precisely the exercise at hand.  Unfortunately, 
this is not implemented in the same way as it is in CPython.  The 
raw_input() function does not interface to it.  So the task is either 
modifying the way raw_input() works or modifying cmd to do something 
else when it looks for input.


> 
> 
>>Anything else I need to be aware of?  Code samples?
>>
> 
> Just grep the standard library for "java".
> 
> 
>>2)  Jython works by referring to a registry file.  Does python also do 
>>this?  If not, is there a way to independently reference system 
>>properties regardless of whether they come from a registry file, 
>>enviroment variables, or some other source?
>>
> 
> What do you mean by registry file? How is that related to the cmd.py
> changes?


Many of the properties used by jython are supplied via a file called 
"registry" located in the jython directory.  In Python, these might be 
supplied by environment variables.  Two of these are vital to the cmd.py 
changes.  One says whether readline is supported at all, and the other 
tells which of several alternative implementations of readline is 
supported.  Wherever this hook is put, these are the properties that 
will have to be inspected to determine how to handle readline.  And, for 
jython, these properties must be accessed through the registry (which is 
an object that jython has access to after it is loaded).


> 
> In general, you give the source of configuration information when
> accessing it, e.g. os.environ, or _winreg. So if you want to read Java
> properties, you should specify them explicitly. You couldn't confuse
> them with environment names, anyway, since they have completely
> different conventions.
> 
> Regards,
> Martin
> 




More information about the Python-list mailing list