{"id":28329494,"url":"https://github.com/mbarde/unikold.connector","last_synced_at":"2025-06-12T04:35:53.482Z","repository":{"id":62586387,"uuid":"182964648","full_name":"mbarde/unikold.connector","owner":"mbarde","description":"Plone-Addon for making cachable queries to API endpoints 🐙","archived":false,"fork":false,"pushed_at":"2023-05-25T09:16:32.000Z","size":2249,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"python3","last_synced_at":"2025-06-02T21:25:52.442Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbarde.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":"LICENSE.GPL","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-23T07:59:58.000Z","updated_at":"2023-05-25T09:16:38.000Z","dependencies_parsed_at":"2022-11-04T07:43:20.040Z","dependency_job_id":null,"html_url":"https://github.com/mbarde/unikold.connector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mbarde/unikold.connector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarde%2Funikold.connector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarde%2Funikold.connector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarde%2Funikold.connector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarde%2Funikold.connector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbarde","download_url":"https://codeload.github.com/mbarde/unikold.connector/tar.gz/refs/heads/python3","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarde%2Funikold.connector/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259398709,"owners_count":22851485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-26T11:12:10.980Z","updated_at":"2025-06-12T04:35:53.467Z","avatar_url":"https://github.com/mbarde.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\nunikold.connector\n=================\n\nPlone-Addon for making cachable queries to API endpoints supporting following protocols:\n\n- Plain XML\n- SOAP (using a fast and modern Python SOAP client: [zeep](https://pypi.org/project/zeep/))\n- LDAP\n\nCan be easily extended.\n\n\nFeatures\n--------------\n\n- SOAP requests are cached (lifetime can be specified)\n- Live-View to test your SOAP requests: `test_soap`: [https://raw.githubusercontent.com/mbarde/unikold.connector/master/docs/connector.gif](https://raw.githubusercontent.com/mbarde/unikold.connector/master/docs/connector.gif)\n- Specific queries (`LSFQuery`, `LSFSearchQuery`) to easily connect to products of [HIS eG](https://www.his.de) via their SOAP API (`dbinterface`)\n- Plain XML requests (also supports basic authentication)\n- LDAP search queries\n\n\nInstallation\n--------------\n\n1. Add `unikold.connector` to your buildout\n2. Install via `prefs_install_products_form`\n3. Create a `SOAPQueriesFolder`\n    * For security reasons `SOAPQueriesFolder` are not globally   addable by default - to be able to add it you need to allow adding this content type at the desired location temporarily\n    * In this folder all queries will be stored\n    * Maybe you also want to exclude it from navigation\n4. Set path to this folder in `@@unikold-connector-controlpanel`\n5. If you want to make use of LSF-Queries you also have to define settings in `@@unikold-connector-lsf-controlpanel`\n6. If you want to make use of LDAP-Queries you also have to define settings in `@@unikold-connector-ldap-controlpanel`\n\n\nExamples\n--------------\n\n### Soap Requests\n\nAfter installing this addon you can make SOAP requests like this:\n\n```python\nfrom unikold.connector.soap import SOAPConnector\nsoapConnector = SOAPConnector(\n    'http://webservices.daehosting.com/services/isbnservice.wso?WSDL',  # URL to WSDL file\n    'IsValidISBN13',                                                    # name of the method\n    '9783492700764',                                                    # method parameter\n    24                                                                  # lifetime of this request in hours\n)\nresponse = soapConnector.get()\n```\n\nIf the request already exists and its lifetime did not expire `soapConnector` simply returns the stored response.\nIf the request exists but is outdated it will be updated before returning the response.\nIf the request does not yet exist, a new object will be created. Its path will be `{SOAP-Queries-Folder}.{WSDL-URL}.{Methodname}.{Parameter}` (where `{SOAP-Queries-Folder}` has to be specified in the controlpanel of this addon - otherwise a folder will be created at your sites' root).\n\nTo get the corresponding query object:\n\n```python\nqueryObject = soapConnector.getQuery()\n```\n\nAbove example without this addon would look like this (remember no persistent objects, no caching):\n\n```python\nfrom zeep import Client\nurl = 'http://webservices.daehosting.com/services/isbnservice.wso?WSDL'\nclient = Client(url)\nresponse = client.service.IsValidISBN13('9783492700764')\n```\n\n### XML Requests\n\nMake a XML request (which will be cached 24 hours):\n\n```python\nfrom unikold.connector.xml import XMLConnector\nxmlConnector = XMLConnector(\n    'https://www.w3schools.com/xml/note.xml',\n    24,\n    queryParams=['prename=Peter', 'surname=Lustig'],  # query parameters (optional)\n    basicAuthCredentials=('username', 'password')  # credentials for basic authentication (optional)\n)\nxmlData = xmlConnector.get()\n# xmlData is a lxml.etree object:\nprint(etree.tostring(xmlData))\n```\n\n### LDAP Requests\n\n```python\nfrom unikold.connector.ldap import LDAPSearchConnector\nsearchFilter = 'mail=mbarde@uni-koblenz.de'\nldapConnector = LDAPSearchConnector(searchFilter=searchFilter)\nresultList = ldapConnector.get()\n```\n\nThis example only works if you set the LDAP default options in `@@unikold-connector-ldap-controlpanel`.\n\nIf you did not set defaults or want to use different values for these options you can also set them explicitly for each query:\n\n```python\nfrom unikold.connector.ldap import LDAPSearchConnector\nsearchFilter = 'mail=mbarde@uni-koblenz.de'\nldapConnector = LDAPSearchConnector(\n    address='ldap://[...]', port=389, baseDN='dc=[...]',\n    searchFilter=searchFilter, username='uid=[...]', password='****',\n    queryLifetimeInHours=24, excludeFromAutoUpdate=True\n)\nresultList = ldapConnector.get()\n```\n\nAutomate updating of queries\n--------------\n\nUse Zope clock server to call `unikold.connector.update` (user must have permission `cmf.ManagePortal`):\n\n```\n[client2]\nzope-conf-additional =\n    \u003cclock-server\u003e\n       method /SiteName/unikold.connector.update\n       period 2880\n       user username\n       password *****\n       host hostname.com\n    \u003c/clock-server\u003e\n```\n\nParameters explained in detail here: https://docs.plone.org/develop/plone/misc/asyncronoustasks.html#clock-server\n\nUpdating big amounts of queries can take a while so its advisable to run the task on a dedicated client.\n\nTo create a query which should be excluded from automatic updates you have to pass `excludeFromAutoUpdate=True` to the corresponding connector.\n\n\nAutomate cleanup of stale queries\n--------------\n\nAnalogous to the usage of `unikold.connector.update` you can use the endpoint `unikold.connector.cleanup` to remove stale query objects. After how many days a query is considered as stale can be specified at `@@unikold-connector-controlpanel`.\n\n\nError logging\n--------------\n\nBy default errors in requests generated by this addon are handled quietly to ensure full functionality even when requested endpoints are not reachable or broken.\nNevertheless you can add [collective.sentry](https://github.com/collective/collective.sentry) to your buildout in order to log those errors.\n\n\nTesting\n--------------\n\nBefore you can run the tests you need to create a file called `config.py` in the `tests` folder,\ncontaining following constants:\n\n```python\n# -*- coding: utf-8 -*-\nsoap_test_url = u'http://webservices.daehosting.com/services/isbnservice.wso?WSDL'\nsoap_test_method = u'IsValidISBN13'\nsoap_test_method_parameter = u'9783492700764'\n\nxml_test_url = u'https://en.wikipedia.org/w/api.php?format=xml\u0026action=query\u0026prop=extracts\u0026exintro\u0026explaintext\u0026redirects=1\u0026titles=Rick_and_Morty'\n\n# config data needed for XML auth tests\nxml_basic_auth_url = u''\nxml_basic_auth_username = u''\nxml_basic_auth_password = u''\n\n# config data needed for LSF tests\nlsf_wsdl_url = u'[...]/qisserver/services/dbinterface?WSDL'\nlsf_test_object_type = u''  # LSF object type\nlsf_test_conditions = []\nlsf_auth_test_object_type = u''\nlsf_auth_test_conditions = []\nlsf_wsdl_search_url = u'[...]/qisserver/services/soapsearch?WSDL'\nlsf_search_test_method_parameter = u''\nlsf_auth_username = u''\nlsf_auth_password = u''\n\n# config data needed for LDAP tests\nldap_server_address = u'ldap://[...]'\nldap_server_port = 389\nldap_server_base_dn = u''\nldap_search_username = u''\nldap_search_password = u''\n\n```\n\n* `bin/test`\n* `bin/code-analysis`\n\nTypeError: string indices must be integers\n--------------\n\nFind monkey patch for https://github.com/mvantellingen/python-zeep/pull/657/commits/a2b7ec0296bcb0ac47a5d15669dcb769447820eb in `patches.py`.\n\n\nLicense\n--------------\n\nThe project is licensed under the GPLv2.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbarde%2Funikold.connector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbarde%2Funikold.connector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbarde%2Funikold.connector/lists"}