is INSTANCE_HOME broken on Win32?
Hello :-) I'm trying to make Squishdot work with INSTANCE_HOME nicely. However, the testing is going wrong on a normal Win32 Install... I had lots of lines that went something like: f=open('%s/Products/%s.dtml' % (SOFTWARE_HOME,file)) Which generates: E:\Zope\2.2.0\lib\python/Products/Squishdot/validArticle.dtml That's not very nice in itself but seems to work with Python's open... However, when I change them all to be like, for example: f=open('%s/Products/%s.dtml' % (INSTANCE_HOME,file)) I then get: 'E:\\Zope\\2.2.0/Products/Squishdot/validArticle.dtml' which is: - horrible - wrong - doesn't work ;-) Anyway, I'm looking for something like INSTANCE_HOME or SOFTWARE_HOME that: - works in an INSTANCE_HOME setup - works in a non-INSTANCE_HOME setup - works on both Unix and Windows.. Any ideas? cheers, Chris
From: Chris Withers <chrisw@nipltd.com>
I'm trying to make Squishdot work with INSTANCE_HOME nicely. However, the testing is going wrong on a normal Win32 Install...
I had lots of lines that went something like:
f=open('%s/Products/%s.dtml' % (SOFTWARE_HOME,file))
Which generates:
E:\Zope\2.2.0\lib\python/Products/Squishdot/validArticle.dtml
That's not very nice in itself but seems to work with Python's open...
However, when I change them all to be like, for example:
f=open('%s/Products/%s.dtml' % (INSTANCE_HOME,file))
I then get:
'E:\\Zope\\2.2.0/Products/Squishdot/validArticle.dtml'
This looks correct to me. If no explicit INSTANCE_HOME is set, it defaults to SOFTWARE_HOME minus '/lib/python'. On the other hand, I wonder why you're constructing '%s/Products/' paths explicitly like this. If this code is inside the Product to which you would like the path, the proper way to get the path is: from Globals import package_home path = package_home(globals()) # path now probably equals 'E:\\Zope\\2.2.0\\lib\\python\\Products\\Squishdot' in your example. I have no idea if or where this is documented, sadly. I'll definitely put it in my 'writing INSTANCE_HOME-friendly Products' howto, as soon as I get around to writing such a thing :-/ Or perhaps you could? ;-) Cheers, Evan @ digicool & 4-am
Evan Simpson wrote:
f=open('%s/Products/%s.dtml' % (SOFTWARE_HOME,file)) E:\Zope\2.2.0\lib\python/Products/Squishdot/validArticle.dtml
f=open('%s/Products/%s.dtml' % (INSTANCE_HOME,file)) 'E:\\Zope\\2.2.0/Products/Squishdot/validArticle.dtml'
This looks correct to me.
Not to me! :-( Okay, I can understand (but not approve of) having a mixture of \ and / in a string (I guess python's open takes care of that) but what's with the \\ in the INSTANCE_HOME case?! Also be my comment on the /lib/python bit below ;-)
If no explicit INSTANCE_HOME is set, it defaults to SOFTWARE_HOME minus '/lib/python'.
Can you explain why that makes sense please ;-) Surely it'd be more useful to default to SOFTWARE_HOME including '/lib/python' so that old code wasn't broken?
On the other hand, I wonder why you're constructing '%s/Products/' paths explicitly like this.
It was done by Butch ages ago. He probably did it 'cos it worked and the 'correct' way wasn't documented anywhere :P
If this code is inside the Product to which you would like the path, the proper way to get the path is:
from Globals import package_home path = package_home(globals()) # path now probably equals 'E:\\Zope\\2.2.0\\lib\\python\\Products\\Squishdot' in your example.
And that'll work in INSTANCE_HOME (in either the base or instance parts) Zope installs as well as non-instance home ones?
I have no idea if or where this is documented, sadly.
no comment ;-)
I'll definitely put it in my 'writing INSTANCE_HOME-friendly Products' howto, as soon as I get around to writing such a thing :-/
Soon, I hope, 'cos it sounds like a great idea
Or perhaps you could? ;-)
The biggest thing I think is needed is a clear definition of what all of these _should_ be and what they _are_. This needs to be done by someone who understands them all and that's clearly not me ;-) cheers, Chris
participants (3)
-
Chris Withers -
Evan Simpson -
Rik Hoekstra