[Zope] reading zope.config file for ClientStorage
Mika, David P (Research)
mika at crd.ge.com
Mon Oct 10 11:44:34 EDT 2005
I've taken a look at stepper and dug into the zope source again. It looks like both are relying on a startup script akin to zopectl to marshal everything correctly. I would rather not be using a startup script (besides I couldn't sort it out); this is what I have so far:
from Zope.Startup import options, handlers
opts = options.ZopeOptions()
opts.configfile='c:\Zope-Instance-Test\etc\zope-with-zeo.conf'
opts.load_schema()
opts.load_configfile()
unfortunately in the resulting options object, I'm not getting the stuff I need from the conf file, namely the ZODB storage stuff needed for ClientStorage.
The schema file that is being used by ZopeOptions is Zope/Startup/zopeschema.xml. This only has a skeleton zodb_db section. It looks like the meat & potatoes are in ZODB/component.xml, but I don't see how that is actually pulled in.
Any more ideas?
Dave
-----Original Message-----
From: Chris Withers [mailto:chris at simplistix.co.uk]
Sent: Monday, October 10, 2005 8:57 AM
To: Mika, David P (Research)
Cc: zope at zope.org
Subject: Re: [Zope] reading zope.config file for ClientStorage
Mika, David P (Research) wrote:
> To initialize ZEO clients with ClientStorage I need info such as host, port, etc. All the needed stuff is tucked away nicely in the zope.config file and I would like to be using the zope machinery access it. I know that what I need is in there somewhere, but when I try to follow how it happens in say the Zope startup, I get lost in all the dependencies and my head starts swirling.
>
> I would like to be able to use something like is in ZODB/config.py:
>
> class ZEOClient(BaseConfig):
>
> def open(self):
> from ZEO.ClientStorage import ClientStorage
> # config.server is a multikey of socket-address values
> # where the value is a socket family, address tuple.
> L = [server.address for server in self.config.server]
> return ClientStorage(
> L,
> storage=self.config.storage,
> cache_size=self.config.cache_size,
> name=self.config.name,
> client=self.config.client,
> var=self.config.var,
> min_disconnect_poll=self.config.min_disconnect_poll,
> max_disconnect_poll=self.config.max_disconnect_poll,
> wait=self.config.wait,
> read_only=self.config.read_only,
> read_only_fallback=self.config.read_only_fallback,
> username=self.config.username,
> password=self.config.password,
> realm=self.config.realm)
>
> here BaseConfig has that bit of magic that has self.config.
>
> I guess I need to know how to instantiate this class. Any ideas?
Have a look at the run.py file in Stepper:
http://www.simplistix.co.uk/software/zope/stepper
It shows you how to parse zope.conf without having to start Zope up...
You may wish to wait for Stepper 1.3.0, though, which shows you how to
do this for both Zope 2.7 and Zope 2.8...
cheers,
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the Zope
mailing list