Configuration file imports don't see INSTANCE_HOME when running zope as a windows service
Bug #143065 reported by
Michael Dunstan
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
Invalid
|
Low
|
Unassigned |
Bug Description
Extensions to zope.conf installed in INSTANCE_HOME of the form::
%import Products.MyProduct
<myproduct>
...
</myproduct>
are not available when running Zope as a windows service. (They are available when running from runzope.bat or other platforms.) From memory the service silently dies when it gets to the import directive.
My hack was to set up a PYTHONPATH to include INSTANCE_HOME before starting PythonService.exe. See patch for details.
To post a comment you must log in.
Status: Pending => Resolved
It's more insidious than that, having just run into this with MailingLogger 2.0.0
Although we now have the shiny new ZConfig zope.conf file, the old environemnt variables will still have an effect.
See findhomes.py in your Zope source tree.
What I experienced was that MailingLogger worked fine on Windows, but not on Linux. The difference I found was that in my linux runzope script, I hadn't exported INTSANCE_HOME, whereas in Windows batch files, you don't get a a lot of choice, the equivalent of a shell script EXPORT happens anyway, whether you want it or not.
Now, it's the presence of the environment variable that makes findhomes.py correctly set up the Products pseudo-module when ZConfig imports Zope's schema.xml. Once that's set up:
%import Products. SomeProduct
...will work, but not before.
Now, the options are:
1. Include the instances's Products path on the PythonPath. NB: This breaks if your Product does:
from Products.MyProduct import x
2. require the INSTANCE_HOME environment variable to still be set when this circumstance arises. This is what I've advised in the MailingLogger documentation.
3. Extend ZConfig to allow %imports to work with things that aren't just on the python path in some way.
Option 1 and 2 work now, and option 3 is a change to ZConfig, which isn't appropriate to discuss in this collector. I'll send a mail to <email address hidden> to kick off the discussion.
As for your specific problem, I'd recommend wrapping zopeservice.py in a batch script or twiddling with the service settings such that INSTANCE_HOME is set before zopeservice.py starts.
I DON'T think zopeservice.py should be changed in the way you suggest.So I'll mark this bug as resolved, and hopefully ZConfic will grow something to support this.