用于发出持久soap请求的plone插件
unikold.connector的Python项目详细描述
单孔连接器
plone插件,用于使用快速而现代的python soap客户端生成持久的soap请求:zeep。
请求被自动存储为SOAPQuery
对象,该对象允许使用响应的可变生存期进行缓存。
功能
- soap请求被缓存(可以指定生存期)
- 测试您的soap请求的实时视图:
test_soap
:https://raw.githubusercontent.com/mbarde/unikold.connector/master/docs/connector.gif - 特定查询(
LSFQuery
,LSFSearchQuery
)可以通过它们的soap api(dbinterface
)轻松连接到HIS eG的产品
安装
- 将
unikold.connector
添加到构建中 - 通过
prefs_install_products_form
安装
- 创建一个
SOAPQueriesFolder
- 出于安全原因,
SOAPQueriesFolder
默认情况下不可全局添加-要添加它,您需要允许在所需位置临时添加此内容类型 - 所有查询都将存储在此文件夹中
- 也许你还想把它排除在导航之外
- 在
@@unikold-connector-controlpanel
中设置此文件夹的路径 - 如果要使用LSF查询,还必须在
@@unikold-connector-lsf-controlpanel
中定义设置
示例
安装此加载项后,您可以发出如下soap请求:
fromunikold.connector.soapimportSOAPConnectorsoapConnector=SOAPConnector('http://webservices.daehosting.com/services/isbnservice.wso?WSDL',# URL to WSDL file'IsValidISBN13',# name of the method'9783492700764',# method parameter24# lifetime of this request in hours)response=soapConnector.get()
如果请求已经存在且生命周期未到期,{{CD12}}只返回存储的响应。
如果请求存在,但已过时,则在返回响应之前将更新该请求。
如果请求还不存在,将创建一个新对象。它的路径将是{SOAP-Queries-Folder}.{WSDL-URL}.{Methodname}.{Parameter}
(其中{SOAP-Queries-Folder}
必须在此加载项的控制面板中指定-否则将在站点的根目录中创建文件夹)。
要获取相应的查询对象:
queryObject=soapConnector.getQuery()
上面没有这个插件的示例将如下所示(记住没有持久对象,没有缓存):
fromzeepimportClienturl='http://webservices.daehosting.com/services/isbnservice.wso?WSDL'client=Client(url)response=client.service.IsValidISBN13('9783492700764')
自动更新查询
使用zope clock server调用unikold.connector.update
(用户必须具有权限cmf.ManagePortal
):
[client2]
zope-conf-additional =
<clock-server>
method /SiteName/unikold.connector.update
period 2880
user username
password *****
host hostname.com
</clock-server>
这里详细解释了参数:https://docs.plone.org/develop/plone/misc/asyncronoustasks.html#clock-server
更新大量查询可能需要一段时间,因此建议在专用客户端上运行该任务。
测试
在运行测试之前,需要在tests
文件夹中创建一个名为config.py
的文件,
包含以下常量:
# -*- coding: utf-8 -*-soap_test_url=u'http://webservices.daehosting.com/services/isbnservice.wso?WSDL'soap_test_method=u'IsValidISBN13'soap_test_method_parameter=u'9783492700764'# config data needed for LSF testslsf_wsdl_url=u''# URL to LSF WSDL file containing getDataXML methodlsf_test_object_type=u''# LSF object typelsf_test_conditions=[]# a list of tuples, i.e. [('prename', 'Peter')]lsf_wsdl_search_url=u''# URL to LSF search WSDLlsf_search_test_method_parameter=u''# XML-formatted parameter for the search method# for testing LSF methods with authenticationlsf_auth_username=u''lsf_auth_password=u''lsf_auth_test_object_type=u''# LSF object typelsf_auth_test_conditions_0=[]# a list of tuples, i.e. [('prename', 'Peter')]lsf_auth_test_conditions_1=[]# a list of tuples, i.e. [('prename', 'Peter')]
bin/test
bin/code-analysis
类型错误:字符串索引必须是整数
确保此修复程序已应用于zeep:https://github.com/mvantellingen/python-zeep/pull/657/commits/a2b7ec0296bcb0ac47a5d15669dcb769447820eb
许可证
该项目是根据gplv2授权的。
贡献者
- 马蒂亚斯·巴德,mbarde@uni-koblenz.de
更改日志
1.0a1(未发布)
- 初次发布。 [mbarde]