[ZODB-Dev] Handling more databases with zeo
Tim Peters
tim at zope.com
Tue Jun 28 15:59:58 EDT 2005
[Lukas Linhart]
> sorry for bothering in Dev list, but I've posted this to c.l.p with no
> answer and I don't knew where to ask.
>
> I've rtfm again and I really don't knew :]
>
> <cite>
> One nice feature of the configuration file is that you don't need
> to specify imports for a specific storage. That makes the code a little
> shorter and allows you to change storages without changing the code.
>
> import ZODB.config
> db = ZODB.config.databaseFromURL('/tmp/zeo.conf')
> </cite>
>
> Well, my goal is to use database via zodb and have db specified in config
> file only.
>
> Thank You for any help,
>
> Almad
Well, immediately following the part you quoted is the zeo.conf file you
could use if you wanted to use a ClientStorage connecting to a ZEO server
listening on localhost port 9100:
<zodb>
<zeoclient>
server localhost:9100
</zeoclient>
</zodb>
I'm not sure what else "db specified in the config file only" could mean, or
how the example failed to illustrate how to do that. It shows how to set up
a config file specifying the storage, and the same application code:
import ZODB.config
db = ZODB.config.databaseFromURL('/tmp/zeo.conf')
then works unchanged no matter which storage is specified in /tmp/zeo.conf.
Maybe you could be more specific about what you want to do?
> -------------- Message from comp.lang.python ----------------------
> Hello,
>
> sorry for bothering with same question again. However, month ago, I have
> tried to handle more zodb databases with zeo as described here:
> http://mail.python.org/pipermail/python-list/2005-May/279915.html
>
> Since then, I don't have had a time to play with it and now I tried
> again. However, even after reading
> http://www.zope.org/Wikis/ZODB/FrontPage/guide/index.html few times, I
> have no idea how to handle this (as anywhere I read, client only connect
> to port and do not select filestorage).
Yes, a ZEO client needs to connect to the hostname:port pair of the ZEO
server it wants to use. There is no possibility to specify the name of an
"arbitrary" FileStorage file when opening a ClientStorage.
> Only possibility I see is to run more zeo instances, which is not
> neccessary as I have read.
What have you read? There _is_ really obscure code that allows for the
possibility of a ZEO server serving more than one database, and in that case
the names are the strings "1", "2", "3", and so on -- there's no choice
about that. I'm not sure this is documented or tested anywhere, and I'm not
sure this is even officially supported anymore. One of the comments in a
current ZODB's ZEO code says:
# @param storage_name a string naming the storage. This argument
# is primarily for backwards compatibility with servers
# that supported multiple storages.
That seems to imply that the author believed servers no longer support
multiple storages, but I really don't know.
In any case, yes, starting one ZEO server per database is what I'd do.
More information about the ZODB-Dev
mailing list