So, I thought of an aternative solution and with a simple example I got it working very smoothly.
I decided to use modjy again. And for a lightweight embeddable servlet container I picked Jetty (5). Modjy has a "reload_on_mod" property that can be set to true if you want the wsgi application that is beeing served checked for modification each time it is called. This only works with one file right now, but could easily be extended.
Firs I unpacked modjy's modjy_webapp directory to a modjy directory and then I wrote this simple script to fire up modjy in Jetty:
from org.mortbay.jetty import Server
server = Server()
server.addListener(":8080")
server.addWebApplication("", "./modjy/")
server.start()
Modjy just worked this time without any hassle :-) So the next thing was to write my CherryPy wsgi application and configre modjy to serve it for me. Very advanced example once again ;-)
import cherrypy
class Root:
def index(self, name="World"):
return "Hello ", name
index.exposed = True
handler = cherrypy.tree.mount(Root())
cherrypy.engine.start(blocking=False)
In modjy's web.xml I had to chage the "app_filenam" to the name of my application and make sure that "python.home" was set correctly and the "reload_on_mod" was set to 1.
A simple change like switching the order of "Hello" and "name" made modjy reload the application and use the modified version. Reload time for this example was next to none as expected.
I might give it a shot at getting modjy to scan a whole directory and its subdirectoies for changes and see how that works out. Oh and this example would probably run on Jython 2.2 with only a couple of minor changes to the CherryPy code... I'll check that and report back.
I've also had some success in using the following setup with Jython: Velocity templates -> CherryPy -> (Spring) -> JPA. I will probably post something about that later on.