[Zconfig] ZConfig example to configure a ZEO client

Dieter Maurer dieter at handshake.de
Thu Feb 17 14:19:38 EST 2005


Willadsens wrote at 2005-2-17 08:58 -0500:
> ...
>>What does this mean? To use something like "zeoctl command"?
>>  
>>
>zeoctl seems to daemonize a process, which will come in handy on the 
>Windows side.

"zdaemon" does not work under Windows.
Therefore, "zeoctl" is out of reach...

>...
>My question was more basic than this, and not really pertaining to this 
>e-list. I just had no clue where to ask it.
>My question is: How do I run a zeo client session purely from the 
>command line? "runzeo.py" is the command line server portion. The doc 
>implies that a client could also be run from the command line, feeding 
>in an XConfig parameter file. But it gives no more info. It is a mystery 
>from that point forward.

Sure, just do it...
Write a (Python) script connecting to ZEO and use the ZODB.
Start it in the same way as you always start.
Be careful about transaction handling. When you do not commit
explicitely, no changes will be saved.

The simplest case looks like:

    zeo_host = ... # the hostname, ZEO runs on
    zeo_port = ... # the port, ZEO listens on

    from ZEO.ClientStorage import ClientStorage
    storage = ClientStorage((zeo_host, zeo_port))
    from ZODB.DB import DB
    db=DB(storage)
    connection = db.open()
    root = connection.root() # this is the ZODB root; dictionary like
    ... do whatever you want ...
    get_transaction().commit() # commit your changes

-- 
Dieter


More information about the ZConfig mailing list