Admittedly, I spent 5 minutes searching and no joy... How does one access INSTANCE_HOME in an external method? The logic I need is something like this--I'm just missing the incantation for my fanciful getZopeEnviron. Help? # a fanciful dream... import os def dostuff(self): location = self.getZopeEnviron("INSTANCE_HOME", None) if not location: location = self.getZopeEnviron("SOFTWARE_HOME", None) if not location: raise PukeOla("What the f---?") import_dir = os.path.join(location, "import") # Now we're cooking with fire... Cheers, // m -
It's just an enviornment variable, so I assume: import os os.getenv('INSTANCE_HOME') should work for an external method.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Mark McEahern Sent: Friday, November 08, 2002 2:06 PM To: Zope Mailing List Subject: [Zope] probably a faq: access INSTANCE_HOME
Admittedly, I spent 5 minutes searching and no joy...
How does one access INSTANCE_HOME in an external method?
The logic I need is something like this--I'm just missing the incantation for my fanciful getZopeEnviron.
Help?
# a fanciful dream...
import os
def dostuff(self):
location = self.getZopeEnviron("INSTANCE_HOME", None) if not location: location = self.getZopeEnviron("SOFTWARE_HOME", None) if not location: raise PukeOla("What the f---?") import_dir = os.path.join(location, "import") # Now we're cooking with fire...
Cheers,
// m
->
Actually it's even easier. It's a builtin. You can refer to INSTANCE_HOME anywhere in a Zope app and it will be returned. On Fri, 2002-11-08 at 17:20, Charlie Reiman wrote:
It's just an enviornment variable, so I assume:
import os os.getenv('INSTANCE_HOME')
should work for an external method.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Mark McEahern Sent: Friday, November 08, 2002 2:06 PM To: Zope Mailing List Subject: [Zope] probably a faq: access INSTANCE_HOME
Admittedly, I spent 5 minutes searching and no joy...
How does one access INSTANCE_HOME in an external method?
The logic I need is something like this--I'm just missing the incantation for my fanciful getZopeEnviron.
Help?
# a fanciful dream...
import os
def dostuff(self):
location = self.getZopeEnviron("INSTANCE_HOME", None) if not location: location = self.getZopeEnviron("SOFTWARE_HOME", None) if not location: raise PukeOla("What the f---?") import_dir = os.path.join(location, "import") # Now we're cooking with fire...
Cheers,
// m
->
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Chris McDonough [mailto:chrism@zope.com]]
Actually it's even easier. It's a builtin. You can refer to INSTANCE_HOME anywhere in a Zope app and it will be returned.
Chris, that did the trick! Thanks! Now, I'm curious how I would find this. It's always interesting to see--even when you know the answer--what sort of google search would turn it up? Google search or searching zope.org's site? This search: http://www.google.com/search?q=instance_home+zope+python+software_home&btnI= I'm%20feeling%20lucky gives some hints. Anything more explicit? For what it's worth, I would expect to see this in the API reference, but it's not there (afaics). Or in the chapter on advanced scripting: http://www.zope.org/Documentation/Books/ZopeBook/current/AppendixB.stx http://www.zope.org/Documentation/Books/ZopeBook/current/ScriptingZope.stx (Not that I looked either place. <grin> Anyway, blimey!) Cheers, // mark -
If possible, please put a comment in the advanced scripting chapter of the zope book noting that INSTANCE_HOME and SOFTWARE_HOME are builtins. Tks! - C On Fri, 2002-11-08 at 17:48, Mark McEahern wrote:
[Chris McDonough [mailto:chrism@zope.com]]
Actually it's even easier. It's a builtin. You can refer to INSTANCE_HOME anywhere in a Zope app and it will be returned.
Chris, that did the trick! Thanks!
Now, I'm curious how I would find this. It's always interesting to see--even when you know the answer--what sort of google search would turn it up? Google search or searching zope.org's site?
This search:
http://www.google.com/search?q=instance_home+zope+python+software_home&btnI= I'm%20feeling%20lucky
gives some hints.
Anything more explicit? For what it's worth, I would expect to see this in the API reference, but it's not there (afaics). Or in the chapter on advanced scripting:
http://www.zope.org/Documentation/Books/ZopeBook/current/AppendixB.stx http://www.zope.org/Documentation/Books/ZopeBook/current/ScriptingZope.stx
(Not that I looked either place. <grin> Anyway, blimey!)
Cheers,
// mark
-
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Chris McDonough [mailto:chrism@zope.com]]
If possible, please put a comment in the advanced scripting chapter of the zope book noting that INSTANCE_HOME and SOFTWARE_HOME are builtins.
Gladly. Done. I even referenced your previous post in case what I wrote required context. http://www.zope.org/Documentation/Books/ZopeBook/current/ScriptingZope.stx (Near the top.) Cheers, // mark -
[Charlie Reiman [mailto:creiman@kefta.com]]
It's just an enviornment variable, so I assume:
import os os.getenv('INSTANCE_HOME')
should work for an external method.
I'm using Zope 2.6.0b2 on Windows--running as a service. Here's the external method contents (below). When I test it, I get HomeNotFoundError. Which suggests that Zope does not set these environment variables for me--I must set them myself. Am I missing something? Thanks, // mark # external method import os class UtilsException(Exception):pass class HomeNotFoundError(UtilsException):pass def import_file(self): location = os.getenv('INSTANCE_HOME') if not location: location = os.getenv('SOFTWARE_HOME') if not location: raise HomeNotFoundError imp_dir = os.path.join(location, 'import') return '\n'.join(os.listdir(imp_dir)) -
participants (3)
-
Charlie Reiman -
Chris McDonough -
Mark McEahern