From: Kent J. <ke...@td...> - 2005-04-23 21:05:24
|
My guess is that JythonServletEchoTest.newApplicationInstance() is just being called once and the result cached by the framework. So changes you make after that point won't be seen no matter what you reload. The reload logic for PyServlet is in the getServlet() method where it looks to see if the timestamp of the file on disk has changed. Kent Joseph Barillari wrote: > (I posted this message yesterday using gmane.org, but I don't think it > got through. Apologies in advance if you get it twice.) > > I've written a tiny python script served by PyServlet that uses the > supremely useful Echo framework (echo.sf.net). It works, but, for some > reason, it doesn't have the ultra-cool reloads-when-you-make-changes > feature of the other "hello world" PyServlets I've played with. > > In other words, I've created the "hello world" servlet described here: > http://seanmcgrath.blogspot.com/JythonWebAppTutorialPart1.html > (specifically, JythonServlet1.py), and the servlet reflects changes as > soon as I save the .py file. But with the Echo servlet I've written, I > have to restart Tomcat for changes to show up. > > Here's the Echo2 Python servlet: > --- cut here --- JythonServletEchoTest.py --- cut here --- > from nextapp.echo2.webcontainer import WebContainerServlet > import nextapp.echo2.app.ApplicationInstance > import nextapp.echo2.app.ContentPane > from nextapp.echo2.app import Extent > from nextapp.echo2.app import Label > from nextapp.echo2.app import Row > import nextapp.echo2.app.Window > > class JythonServletEchoTest (WebContainerServlet): > def newApplicationInstance(self): > return TestApp() > > class TestApp(nextapp.echo2.app.ApplicationInstance): > def init(self): > mainWindow = nextapp.echo2.app.Window() > mainWindow.setTitle("Echo2+Jython Test") > mainWindow.setContent(testPane()) > return mainWindow > > class testPane(nextapp.echo2.app.ContentPane): > def __init__(self): > nextapp.echo2.app.ContentPane.__init__(self) > self.add(Label("Hello world!")) > --- cut here --- JythonServletEchoTest.py --- cut here --- > > WebContainerServlet is a subclass of HttpServlet, so I'd think this > should operate similarly to the JythonServlet1 example. But it > doesn't: if I change "Hello world!" to something else, I have to > restart Tomcat for the servlet to reflect that. > > Obviously, it wouldn't be fair to ask for a solution (since this isn't > an Echo forum), but I'm curious if someone can give me an idea of > where to look in Jython/PyServlet to see why the auto-reload feature > isn't working. After all, PyServlet is processing the .py file -- > surely, it must be involved, whether I pass the request to > HttpServlet, Echo's WebContainerServlet, or whatever. How it could > fail is the area where I'm curious. (Also -- is there any way to > _force_ the reloading of a module? I tried splitting TestApp into a > separate file and calling reload() on it, but that didn't work.) > > I'm using tomcat 4.1, debian unstable, java version "1.4.2_06" > Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03) > Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode) > > Any suggestions would be much appreciated. thanks in advance! > > --Joe > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |