collective / sauna.reload

Instant code reloading for Plone using a fork loop.
http://pypi.python.org/pypi/sauna.reload/
Other
11 stars 5 forks source link

Instance won't start with sauna.reload #8

Closed kcleong closed 11 years ago

kcleong commented 12 years ago

I'm having a strange behaviour with sauna.reload and Plone 4.2.1. If I add sauna.reload to my development buildout, the zope instance fails to start. I've got a stack trace where I've got a zcml error on 'directive factory' in zope.site.

Stack trace: http://pastebin.com/tgXaD5sY

I'm running other similar buildouts where sauna.reload is working ok.

datakurre commented 12 years ago

Thanks for reporting. I'll describe the reason for this shortly.

datakurre commented 12 years ago

I believe, the error happens, when sauna.reload tries to load dependencies for reloadable packages under RELOAD_PATH.

Because sauna.reload doesn't really know why dependency packages are required, it blindly autoincludes meta.zcml, configure.zcml and overrides.zcml from them. Actually, this is almost a copy of what <five:includeDependencies/> from z3c.autoinclude does.

So, in some dendency of some package in RELOAD_PATH, there's a meta.zcml, configure.zcml or overrides.zcml which is never meant to be loaded for Plone. Yet, sauna.reload loads it and crashes the startup.

The only solution for this, so far, has been blacklisting those packages (so that they are only loaded by the relaoded package).

See also: https://github.com/collective/sauna.reload/blob/master/sauna/reload/autoinclude.py#L54

Yes, this is ugly and is known to cause problems. I'm sorry about that. If you find the package in question, we could add it into black list. In the long term, however, we should implement a way to configure sauna.reload more and make this magical (and error causing) behavior optional.

kcleong commented 12 years ago

I've added 'zope.site' to the blacklisted packages, the Plone instance is starting up with this change. In other buildouts with the same Plone version, zope.site is also used and sauna.reload is working. I'm not quite sure is this helps, because I'm getting errors when reloading code:

2012-11-02 10:57:11 ERROR sauna.reload.child Cannot reload src/plone.app.discussion/plone/app/discussion/notifications.zcml.

I will try to find out why the error is happening when reloading code. In this particular buildout we've got many third-party packages, and about 10 packages in the reload path.

datakurre commented 12 years ago

Ok. Probably some reloadad package (in the failing setup) has direct dependency on 'zope.site' in its setup.py. I think, we should add 'zope.site' into blacklisted packages.

This is a different (and more regular) error:

2012-11-02 10:57:11 ERROR sauna.reload.child Cannot reload src/plone.app.discussion/plone/app/discussion/notifications.zcml.

It means that sauna.reload couldn't prevent plone.app.discussion being loaded before the reload point. And that's because some non-reloaded packages requires it.

Because the package in question is "plone.app.discussion", it's because it's directly included in configure.zcml of CMFPlone.

Unfortunately, I have no nice solution for this. Because, that's how sauna.reload works :(

If it's not too much work, you can remove/comment <include package="plone.app.discussion" /> in configure.zcml of CMFPlone for your development purposes (and make sure that some of your own packages, e.g. a policy, requires or includes it).

We don't do that automatically, because we cannot know, if the package including our reloaded package would really require its code and fail it it's not include. Because CMFPlone includes plone.app.discussion only to automatically install and configure it with Plone, we can safely remove that include in development (and make sure that we directly include plone.app.discussion in our code to make it loaded).

datakurre commented 11 years ago

I guess, this is kind of wontfix and can be closed.