Jython Monthly

http://www.jython.org/css/jython.png

January 2007 -- Issue #7

Welcome to the January 2007 issue of Jython Monthly. The content of this newsletter will focus on using and developing the Jython languge. I want to encourage the readers of Jython Monthly to send any articles, tips, tricks, or any other Jython related material to me if you think it should be distributed with this newsletter.

This month's newsletter includes two articles which should be of interest. The first article explains how to develop a Jython web application using web.py. This appears to be a powerful alternative way to develop Jython web applications. The second article shows how you can translate a Java program into Jython and make it work with the JOGL API.

You will also see some excellent Python tips in this month's distribution. Each of these tips have been taken from the Python Cookbook and tested under Jython.

Special thanks to those who submitted material for this month's newsletter!

- Josh Juneau

Questions, comments, or suggestions?

Please send email to:

jython-monthly@mchsi.com or jython-users@lists.sourceforge.net for discussion.

Articles

Web Application Development Using web.py and Jython

Submitted by: Colin

Given the recent discusion on the Jython-dev list of getting popular CPython applications ported to run on Jython I took a look at whether it was possible to get the increasingly poplar web.py web appplication (anti)framework to work on the Jython platform. It turned out it was relatively easy to get it running and most of the basic functionality working: db connectivity, form.py and template.py.

[http://wiki.python.org/jython/JythonMonthly/Articles/January2007/1 Read entire article]

Proof of Concept: Using Jython with the JOGL API

Submitted by: Josh Juneau

My everyday job consists of Java and/or PL/SQL programming and database development. That is why I thought it would be fun to start looking into Java and Jython game development for something fun. I've chosen to implement a Jython program which utilizes the Java Binding for OpenGL (JOGL) API. This brief article is not meant to be a tutorial for using JOGL API as there are many good references already available (see below), but rather it is meant to be a "proof-of-concept" that Jython does work with JOGL for the most part.

[http://wiki.python.org/jython/JythonMonthly/Articles/January2007/2 Read entire article]

Off The Lists

Question from "Divya":

I would like to parse ". java " / ".class" files and detect class name's, attributes name's and type's (and or list of methods).

Is there any module who can parse easily a java file using jython?

Answer from Luis:

It would probably be easiest to work on compiled .class files and use the reflection API.

If you have access to Java 6, you could even use the compiler API. See the following article:

http://www.javalobby.org/java/forums/t44534.html


Question from Mike:

I'm embedding Jython in a Java servlet and have set the 'python.path' to include a directory which contains python scripts I have written and packaged.

For example I have a folder "/package" which contains 'myscript.py' and 'init.py'.

My servlet executes some arbitary python script which imports the module 'myscript'. The first time this happens 'myscript.py' is compiled to 'myscript$py.class' which is fine. However, if I change 'myscript.py' there is no detection of the new script and I must shutdown and restart the servlet to reload my changes.

Is there any simple way around this?

Answer from Leouser:

have you tried the reload function yet?

{{{import Thing Thing.doSomething() #change Thing.py src reload(Thing) Thing.doSomething() }}}

Interested in Developing Jython?

If you are interested in developing Jython, please take a look at the [http://sourceforge.net/tracker/?func=browse&group_id=12867&atid=112867 current bug listing] and submit patches for items which you can repair.

Tips and Tricks

[http://aspn.activestate.com:80/ASPN/Cookbook/Python/Recipe/499295 Python Cookbook: Reload Classes Dynamically]

[http://aspn.activestate.com:80/ASPN/Cookbook/Python/Recipe/499296 Python Cookbook: The KeyedDict object keeps a list of approved key values]

[http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/499304 Python Cookbook: Calculate hamming distance between two strings]

Noteworthy Book Releases

[http://www.techbookreport.com/tbr0278.html Python Phrasebook]

Jython Blogs

[http://gushieblog.blogspot.com:80/ Great Jython blogs from Paul Drummond]

[http://henkenotes.blogspot.com/2006/12/cherrypy-jython-modjy-jboss-true.html CherryPy + Jython + modjy + JBoss = true]

[http://gushieblog.blogspot.com/2006/12/handling-method-arguments-in-jython.html Handling Method Arguments in Jython]

Interesting Facts

Jython - Average Job Salary & Stats in UK http://www.itjobswatch.co.uk/jobs/uk/jython.do

Useful Links

Links

[http://www.jython.org Jython Home]

[http://www.python.org Python Home]

[http://en.wikipedia.org/wiki/Jython Jython WikiPedia]

[http://freshmeat.net/projects/jython/ Freshmeat.net]

[http://www.pythonware.com/daily/ Python Daily News]