Package: zeo_connector
IntroductionWrappers, which make working withZEOlittle bit nicer.By default, you have to do a lot of stuff, like create connection to database, maintain it, synchronize it (or running asyncore loop), handle reconnects and so on. Classes defined in this project makes all this work for you at the background.DocumentationThis module defines three classes:ZEOWrapperPrototypeZEOConfWrapperZEOWrapperZEOWrapperPrototypeZEOWrapperPrototypecontains methods and shared attributes, which may be used by derived classes.You can pretty much ignore this class, unless you want to make your own connector.ZEOConfWrapperZEOConfWrappermay be used to create connection to ZEO fromXML configuration file.Lets say you have file/tests/data/zeo_client.conf:<zeoclient>serverlocalhost:60985</zeoclient>You can now create theZEOConfWrapperobject:fromzeo_connectorimportZEOConfWrapperdb_obj=ZEOConfWrapper(conf_path="/tests/data/zeo_client.conf",project_key="Some project key",)and save the data to the database:importtransactionwithtransaction.manager:db_obj["data"]="some data"String"some data"is now saved underdb._connection.root()[project_key]["data"]path.ZEOWrapperZEOWrapperdoesn’t use XML configuration file, but direct server/port specification:fromzeo_connectorimportZEOWrapperdifferent_db_obj=ZEOWrapper(server="localhost",port=60985,project_key="Some project key",)So you can retreive the data you stored into the database:importtransactionwithtransaction.manager:printdifferent_db_obj["data"]Running the ZEO serverThe examples expects, that the ZEO server is running. To run the ZEO, look at the help page of therunzeoscript which is part of the ZEO bundle. This script requires commandline or XML configuration.You can generate the configuration files using providedzeo_connector_gen_defaults.pyscript, which is part of thezeo_connector_defaults <https://github.com/Bystroushaak/zeo_connector_defaults>package:$ zeo_connector_gen_defaults.py --help
usage: zeo_connector_gen_defaults.py [-h] [-s SERVER] [-p PORT] [-C] [-S]
                                     [PATH]

This program will create the default ZEO XML configuration files.

positional arguments:
  PATH                  Path to the database on the server (used in server
                        configuration only.

optional arguments:
  -h, --help            show this help message and exit
  -s SERVER, --server SERVER
                        Server url. Default: localhost
  -p PORT, --port PORT  Port of the server. Default: 60985
  -C, --only-client     Create only CLIENT configuration.
  -S, --only-server     Create only SERVER configurationFor example:$ zeo_connector_gen_defaults.py /tmpwill createzeo.conffile with following content:<zeo>addresslocalhost:60985</zeo><filestorage>path/tmp/storage.fs</filestorage><eventlog>levelINFO<logfile>path/tmp/zeo.logformat%(asctime)s%(message)s</logfile></eventlog>andzeo_client.confcontaining:<zeoclient>serverlocalhost:60985</zeoclient>You can change the ports and address of the server using--serveror--portarguments.To run the ZEO with the server configuration file, run the following command:runzeo -C zeo.confTo run the client, you may useZEOConfWrapper, as was show above:fromzeo_connectorimportZEOConfWrapperdb_obj=ZEOConfWrapper(conf_path="./zeo_client.conf",project_key="Some project key",)InstallationModule ishosted at PYPI, and can be easily installed usingPIP:sudo pip install zeo_connectorSource codeProject is released under the MIT license. Source code can be found at GitHub:https://github.com/Bystroushaak/zeo_connectorUnittestsYou can run the tests using providedrun_tests.shscript, which can be found in the root of the project.If you have any trouble, just add--pdbswitch at the end of yourrun_tests.shcommand like this:./run_tests.sh--pdb. This will drop you toPDBshell.RequirementsThis script expects that packagepytestis installed. In case you don’t have it yet, it can be easily installed using following command:pip install --user pytestor for all users:sudo pip install pytestExample$ ./run_tests.sh
============================= test session starts ==============================
platform linux2 -- Python 2.7.6 -- py-1.4.30 -- pytest-2.7.2
rootdir: /home/bystrousak/Plocha/Dropbox/c0d3z/python/libs/zeo_connector, inifile:
plugins: cov
collected 7 items

tests/test_zeo_connector.py .......

=========================== 7 passed in 7.08 seconds ===========================Changelog0.4.8ZEO version un-pinned. Will continue inhttps://github.com/zopefoundation/ZEO/issues/770.4.7Pinned older version of ZEO.0.4.6Cleanup of metadata files.0.4.0 - 0.4.5Added@retry_and_resetdecorator for all internal dict-methods calls.Project key is now optional, so this object may be used to access the root of the database.PropertyASYNCORE_RUNNINGrenamed to_ASYNCORE_RUNNING.Implemented.pack().Added@transaction_manager.Addedexamples/database_handler.pyand tests.Added @wraps(fn) to decorators.Added requirement for zope.interface.Attempt to solvehttps://github.com/WebArchivCZ/WA-KAT/issues/860.3.0Environment generator and other shared parts moved tohttps://github.com/Bystroushaak/zeo_connector_defaultsREADME.rst improved, added more documentation and additional sections.0.2.0Added standard dict methods, like.__contains__(),.__delitem__(),.__iter__()and so on.0.1.0Project created.