包装纸,这使与Zeo的工作有点好。

zeo_connector的Python项目详细描述


简介

https://badge.fury.io/py/zeo_connector.pnghttps://img.shields.io/pypi/dm/zeo_connector.svghttps://img.shields.io/pypi/l/zeo_connector.svghttps://img.shields.io/github/issues/Bystroushaak/zeo_connector.svg

包装纸,使工作与ZEO有点好。

默认情况下,您需要做很多事情,比如创建到数据库的连接、维护它、同步它(或运行异步循环)、处理重新连接等等。在这个项目中定义的类使所有这些在后台工作。

文件

本模块定义了三个类:

  • ZEOWrapperPrototype
  • ZEOConfWrapper
  • ZEOWrapper
ZeowRapperPrototype公司

ZEOWrapperPrototype包含可由派生类使用的方法和共享属性。

你可以忽略这个类,除非你想建立自己的连接器。

zeoconfwrapper

ZEOConfWrapper可用于从XML configuration file创建到zeo的连接。

假设您有文件/tests/data/zeo_client.conf

<zeoclient>serverlocalhost:60985</zeoclient>

现在可以创建ZEOConfWrapper对象:

fromzeo_connectorimportZEOConfWrapperdb_obj=ZEOConfWrapper(conf_path="/tests/data/zeo_client.conf",project_key="Some project key",)

并将数据保存到数据库:

importtransactionwithtransaction.manager:db_obj["data"]="some data"

字符串"some data"现在保存在db._connection.root()[project_key]["data"]路径下。

zeowrapper

ZEOWrapper不使用XML配置文件,而是直接服务器/端口规范:

fromzeo_connectorimportZEOWrapperdifferent_db_obj=ZEOWrapper(server="localhost",port=60985,project_key="Some project key",)

因此,您可以检索存储在数据库中的数据:

importtransactionwithtransaction.manager:printdifferent_db_obj["data"]

运行zeo服务器

示例预期zeo服务器正在运行。要运行zeo,请查看作为zeo包一部分的runzeo脚本的帮助页。此脚本需要命令行或XML配置。

您可以使用提供的zeo_connector_gen_defaults.py脚本生成配置文件,该脚本是zeo_connector_defaults<;https://github.com/bystroushaak/zeo_connector_defaults>;包的一部分:

$ 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 configuration

例如:

$ zeo_connector_gen_defaults.py /tmp

将创建包含以下内容的zeo.conf文件:

<zeo>
  address localhost:60985
</zeo><filestorage>
  path /tmp/storage.fs
</filestorage><eventlog>
  level INFO
  <logfile>
    path /tmp/zeo.log
    format %(asctime)s %(message)s
  </logfile></eventlog>

以及zeo_client.conf包含:

<zeoclient>
  server localhost:60985
</zeoclient>

您可以使用--server--port参数更改服务器的端口和地址。

要使用服务器配置文件运行zeo,请运行以下命令:

runzeo -C zeo.conf

要运行客户机,可以使用ZEOConfWrapper,如上所示:

fromzeo_connectorimportZEOConfWrapperdb_obj=ZEOConfWrapper(conf_path="./zeo_client.conf",project_key="Some project key",)

安装

模块是hosted at PYPI,可以使用PIP

轻松安装
sudo pip install zeo_connector

源代码

项目是在麻省理工学院的许可下发布的。源代码可以在github找到:

单元测试

您可以使用提供的run_tests.sh脚本运行测试,该脚本可以在项目的根目录中找到。

如果有任何问题,只需在run_tests.sh命令的末尾添加--pdb开关,如下所示:./run_tests.sh --pdb。这会把你扔到PDB外壳上。

要求

此脚本要求安装包pytest。如果您还没有安装,可以使用以下命令轻松安装:

pip install --user pytest

或者对于所有用户:

sudo pip install pytest

示例

$ ./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 ===========================

更改日志

0.4.8

0.4.7

  • Pinned older version of ZEO.

0.4.6

  • Cleanup of metadata files.

0.4.0-0.4.5

  • Added ^{tt19}$ decorator for all internal dict-methods calls.
  • Project key is now optional, so this object may be used to access the root of the database.
  • Property ^{tt20}$ renamed to ^{tt21}$.
  • Implemented ^{tt22}$.
  • Added ^{tt23}$.
  • Added ^{tt24}$ and tests.
  • Added @wraps(fn) to decorators.
  • Added requirement for zope.interface.
  • Attempt to solve https://github.com/WebArchivCZ/WA-KAT/issues/86

0.3.0

0.2.0

  • Added standard dict methods, like ^{tt25}$, ^{tt26}$, ^{tt27}$ and so on.

0.1.0

  • Project created.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java为什么hashmap对整数值求和   使用copyFromRealm发送副本时,从错误线程访问java领域异常   java NDK支持是一个实验性的特性,所有用例都还不支持。Android Studio中的错误?   Java从resultSet生成查询并执行新查询   youtube如何使用Java+Google数据API测量上传比特率   如何从Java调用Xtend代码?   在java中,如何清除每个方法中的字节[]数组以保护值不被内存转储?   java UTF8编码与Base64编码   (与java inorder一起提供的反应式处理和反应式反应器:MWIO.3)   带toString的java Building 9x9   java如何在GridLayout中根据手机屏幕对齐按钮?   将字符串值解析为整数时出现java错误   java activeMQ接收器倒带丢失?   jfree图表中范围标记标签的java包装文本   java Android播放列表查询不准确。。。?   当请求中的头{“Accept”:“application/octetstream”}出现错误时,java返回JSON   javanet。ucanaccess。jdbc。UcanaccessSQLException   java Hibernate注释用于自动增量,但如果在保存之前设置了值,则还应保存该值