|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Reloading of django views.py in modjyHi all,
I'm new here so if this is the wrong place for this question don't hesitate to yell at me :-) I'm trying to run django inside a WAR file with modjy on a JBoss 4.2.2 Application server. (Next step is to integrate it into a jboss seam project) The deployment time isn't great so I'm trying to get jython/modjy to reload my django application on change of a source file, as in the development server of django. I tried a lot of things. modjy will reload application.py on modification, so I tried to manually reload my views.py. Something like: def handler(environ, start_response): os.putenv("DJANGO_SETTINGS_MODULE", "clean.settings") h = wsgi.WSGIHandler() import hello.views reload(hello.views) return h(environ, start_response) Didn't work. So I tried further to remove the views$py.class file, and indeed it get's compiled if I remove it manually and touch application.py causing modjy to reload it and in turn triggers my import. An judging by changing filesize of views$py.class it would seem it's the updated views.py it compiles, but it still runs the old code! If I remove both views.py and it's class, then touch application.py i get a "No module named views" error... So basically: 1) Has anyone done anything like this? 2) Why does it not execute the compile code? (is it a java thing?) 3) Am I barking up the wrong tree? If anyone has any clue what I could try next It would be greatly appriated! Thanks! /davidj ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Reloading of django views.py in modjyOn Tue, Jun 16, 2009 at 12:23 PM, David Jensen<david.lgj@...> wrote:
> Hi all, > > I'm new here so if this is the wrong place for this question don't > hesitate to yell at me :-) > > I'm trying to run django inside a WAR file with modjy on a JBoss 4.2.2 > Application server. (Next step is to integrate it into a jboss seam > project) > The deployment time isn't great so I'm trying to get jython/modjy to > reload my django application on change of a source file, as in the > development server of django. > > I tried a lot of things. modjy will reload application.py on > modification, so I tried to manually reload my views.py. Something > like: > > def handler(environ, start_response): > os.putenv("DJANGO_SETTINGS_MODULE", "clean.settings") > h = wsgi.WSGIHandler() > import hello.views > reload(hello.views) > return h(environ, start_response) > > Didn't work. First, I'm not familiar with modjy's reloading logic. But I can shed some light on some of your questions. First, unfortunately reload(foo) isn't enough as a reload strategy. It will make Jython to recompile the module, will update it's entry on sys.modules and will *return* the updated module. But if other modules have a binding with the old module (which is what import do!), such bindings won't be refreshed. So, what's happening here is that Django holds a reference to the non-updated hello.views module. > So I tried further to remove the views$py.class file, and > indeed it get's compiled if I remove it manually and touch > application.py causing modjy to reload it and in turn triggers my > import. > An judging by changing filesize of views$py.class it would seem it's > the updated views.py it compiles, but it still runs the old code! That supports my explanation given above. [...] > So basically: > 1) Has anyone done anything like this? > 2) Why does it not execute the compile code? (is it a java thing?) > 3) Am I barking up the wrong tree? I don't have good answers here. If you already have discarded the usage of the development server (jython manage.py runserver), I'd like to hear why. Perhaps we can improve it and solve your problem. But my take on the issue is that modjy's reloading strategy is falling short on your use case and should be improved. If you fill an issue on <http://bugs.jython.org> (so this doesn't get forgotten) you will probably be helping to make Jython better! -- Leo Soto M. http://blog.leosoto.com ------------------------------------------------------------------------------ _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Reloading of django views.py in modjy[Leo]
> But my take on the issue is that modjy's reloading strategy is falling > short on your use case and should be improved. If you fill an issue on > <http://bugs.jython.org> (so this doesn't get forgotten) you will > probably be helping to make Jython better! Modjy permits two ways to specify an application. 1. By directory/filename/callable_name triple. http://opensource.xhaus.com/projects/modjy/wiki/ModjyAppExecFile The contents of the file specified by directory/filename are execfile()d, and the callable name extracted from the resulting namespace. If the "reload_on_mod" flag is true, then the file containing the application code is checked for modification, and re-execfile()ed if the file has been modified. If there are dependent modules that are imported as a result of the execfile, then those dependent modules should also be re-compiled and imported. 2. By specifying an importable name. http://opensource.xhaus.com/projects/modjy/wiki/ModjyAppImportable When an applicaiton is specified this way, e.g. "some_framework.web.handlers.WSGIHandlerClass()", the name is imported, and perhaps instantiated, using the standard jython import machinery. As stated on the above page, source reloading *is not supported* when using the importable name mechanism. In this scenario, the only way to get an application reload is to restart the entire web application, AFAIK. So, some questions to the OP 1. What application mechanism are you using? 2. Are you using the "reload_on_mod" flag? Probably best if you could tell us the values of all of the modjy configuration variables you are using. Alan. ------------------------------------------------------------------------------ _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
| Free embeddable forum powered by Nabble | Forum Help |