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: plone
https://bugs.launchpad.net/grok/+bug/213269
/@@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).
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 ...
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.
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