Friday, January 25

Fewer Zope Server restarts

In my ongoing attempt to make filesystem based Zope development faster, I had a look at the nice but somewhat scary RefreshNG product.

One of the nice things which I thought about myself is its ability to reload all ZCML and reconfigure the global site manager without a server restart.

I took that idea and made it into its own package plone.reload which has a first release at http://pypi.python.org/pypi/plone.reload/0.1. All you need to do is to call http://server:port/@@zcml_reload while being logged-in as a Manager. You can do that as often as you like :)

Casual testing tells me that it should work in a standard Zope2 or Plone environment, though I only tested it against Zope 2.11 / Plone 4.0.

Feedback and bug reports welcome ;)

Update:

Sorry for the premature announcement. It seems there is some caching going on, which I need to work around. Probably this happens thanks to the new local site manager... Right now changing global GenericSetup steps works fine, but not much more. I'll post an update once I have tested this myself more thoroughly.

Update 2:

I got a new 0.3 release out, which should fix the caching issues. Sadly it does so by invalidating all the ZODB caches, which means you will wait a bit more after hitting the Force-Reload button in your browser. I found that just refreshing the site gave an acceptable wait-time, though.

5 comments:

Graham John Perrin said...

During my buildout (Plone 3.0.5 Unified Installer Plus Buildout (Experimental)) the following lines appeared

Getting distribution for 'plone.reload'.
Got plone.reload 0.1.

but then tagging /@@zcml_reload to the root URL of my site results in

Resource not found

Regards
Graham

Jon Stahl said...

I'm curious to hear more about why RefreshNG is "nice but scary."

Hanno Schlichting said...

@graham: Make sure you loaded the packages configure.zcml. In buildout via the zcml option of the instance recipe and you use the ZODB root and not a Plone site as the base url - in a ZEO environment you usually need to use the port number of one of the ZEO clients and not port 8080 which might be rewritten to the Plone site.

@jon: The idea of reloading only parts of your running Python code witout a full restart is pretty nice, especially as it can be done automatically. The problem is the exact way you do this. While refreshng uses a more subtle way than the old Zope2 product refresh which is less likely to break it still cannot support many of the ways in which we write code. While some could probably be added like support for decorators or class methods, other techniques like monkey patching are inherently more difficult to support. At this point I'd say that you could use refreshng for your own add-ons but using it against anything in the Plone core distribution is likely to cause problems.

maurits said...

I could not wait to try this out. :)

I tried this on both Plone 3.0.5 and on ploneout trunk. Calling @@zcml_reload on the zope root goes fine, but I see nothing happening.

What I tried is simply changing the name of a browser view (breadcrumbs_view => breadcrumbs_view2). After reloading the zcml, the old view was still available (fine with me really), but the new view could not be found.

Is this the kind of zcml change that should work with plone.reload? Or should I be trying different things?

tomster said...

Is this only supposed to pick up ZCML changes? I tested it with Plone 3.0.5 and got the expected Global ZCML reloaded. message, but changes to a view class weren't picked up. (That's all I'm interested in ATM...)

So, should that work or am I expecting too much? At any rate, thanks hannosch for venturing into this area!