Restarting zope for plone developmentΒΆ

Tags: plone, work

In ye olde barbaric days, one thing was handy: templates and python scripts reloaded just fine in debug mode and a refresh.txt in your product went a long way to not having to restart your zope too often.

Zcml only loads on startup, so a change there means a zope restart, probably nothing to be done about that. But I seem to be restarting zope for just about every single little python change.

So I asked around on the mailinglist last month: on the current strategies for preventing too many zope restarts during development?  I was bound to miss a few tips and tricks otherwise :-) So here's a summary.

  • Raphael Ritz had the shortest answer: TDD. Yes, test driven development is   core to preventing restarts as you minimize the amount of in-browser testing   and trying.
  • I've tried RefreshNG and that seemed to   work reasonably OK. Not all the time, but it helped. Andreas Jung rightfully   mentioned it. I didn't install it in the last projects I worked on: time for   a more focused test later this month.
  • Kai points towards my restart-preventing product of   choice: pyflakes   . The best python syntax checker available! Missing imports, = instead of   ==, head-slapping stuff like that. Catch it before restarting zope :-)
  • Kai again: PDBDebugMode can help you to find a solution exactly at the point   of error. It does actually prevent try-error-retry restarts and is a joy to   use.

Martin Aspeli provided the full list of rules on what requires a restart:

  • If you are in non-debug-mode, a restart is required for any change at all,   more or less.
  • If you are in debug mode, any .pt file changed anywhere does not require a   restart
  • If you are in debug mode, any Zope 3 browser resource (accessed with the   ++resource++ namespace) can be changed without a restart
  • GenericSetup XML files and Install.py files (unless there's also an   Install.pyc file, but you can delete it while Zope is running) created in   Extensions for use by portal_quickinstaller can be changed without a   restart. However, a custom setuphandler in a normal .py file cannot be   change.d
  • Anything in a skin layer will not require a restart - that includes Script   (Python)'s.
  • Any other kind of .py file change will require a restart
  • Any ZCML change will require a restart

Those plone mailing lists sure are great :-)

Tags:

(Old imported comments)
"paster serve auto-restarts?" by http://kteague.myopenid.com/ on 2008-04-12 01:23:51
CherryPy and Django have a thread that stats files every second and restarts the server process when it detects changes. paster serve has a similar feature (--reload and --reload-interval=SECONDS), so running Grok (or Plone) as a WSGI app under paster serve would at least automate the process of restarting Zope. Grok restarts are ~2 seconds, so it's not too bad - Plone restarts take a wee bit longer though.

https://bugs.launchpad.net/grok/+bug/213269

"plone.reload" by http://silviot.myopenid.com/ on 2008-04-11 23:29:44
Have a look at plone.reload in the cheeseshop. It's based on RefreshNG and gives two views for the zope root: /@@code_reload and /@@zcml_reload.
/@@code_reload didn't work for me for a portlet renderer, but moving the renderer class definition to a separate file and importing the renderer in the file referenced by the zcml worked.
I guess it has to do with ZCA registration.
But in most cases it works well (and saves time).
"workaround for restart" by http://ed.crewe.cmetc.myopenid.com/ on 2008-04-11 15:29:04
For quicker mycode.py debug purposes you can also use another zeo client for debug, rather than restarting and manually testing methods e.g. for setuphandlers.py for instance:

bin/zeo_client_2 debug < mytest.py

where mytest.py might be:

from mysite.theme.setuphandlers import SiteSetup
cp = SiteSetup()
cp.MyMethodToTest(app.plonesite)

... then maybe evolve it into a more formal unit or doc test later ...
"Thanks" by reinout on 2008-01-18 00:02:23
Thanks a lot for the positive feedback, Maurizio. Since I got the feedback I told about in http://vanrees.org/[...]/ecppm-2004-wednesday-afternoon-notes-part-2 , I started to take my writing/reporting skills more seriously. It is a skill I have: that brings the responsibility to use it and to improve it.

Luckily I like to do it :-)

I've recently made the decision to increase the frequency with which I blog (and not only on plone, so not all of it will show up on planet.plone.org). Your positive feedback helps a lot in strengthening that resolve.

It also means that I'm also inviting negative (or "improvement-oriented") feedback in order to improve myself. I really really want to learn.
"Thanks Reinout!" by http://miziodel.myopenid.com/ on 2008-01-17 22:56:13
again.. for this great summaries of yours!

mailing lists are really helpful, and all the plone people is kicking ass, but you rule, and i propose you as one of the best plone reporter out there!

hope you'll have a great 2008 and to meet you soon!

Maurizio
blog comments powered by Disqus
 
vanrees.org logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):