URL escaping is basically managed by PyHole. Example:
>>> from pyhole import PyHole
>>> proxy = PyHole('http://domain.tld/rest_api')
>>> proxy['text and spaces']
http://domain.tld/rest_api/text%20and%20spaces
>>> proxy(param='some/path')
http://domain.tld/rest_api?param=some%2Fpath
Force trailing slash is off by default not to confuse a simple use like this:
>>> from pyhole import PyHole
>>> proxy = PyHole('http://domain.tld/rest_api')
>>> proxy['just_run_this.php']
http://domain.tld/rest_api/just_run_this.php
Turning it on
>>> from pyhole import PyHole
>>> proxy = PyHole('http://domain.tld/rest_api', force_slash=True)
will cause a bad effect in this case
>>> proxy['just_run_this.php']
http://domain.tld/rest_api/just_run_this.php/
From the other hand, following this url design philosophy requires to use force_slash=True
>>> proxy.this.looks.just.nice
http://domain.tld/rest_api/this/looks/just/nice/
Whenever data returned from API is in yaml format, PyHole can un yaml it on every request.
PyHole support for yaml that process every response with yaml.load function
Just import PyHoleYamled instead of PyHole
>>> from pyhole.yamled import PyHoleYamled
the pyhole api is the same, only on every post() and get() data will be yaml.load().
Whenever data returned from API is in json format, PyHole can un json it on every request.
PyHole support for yaml that process every response with yaml.load function
Just import PyHoleJsoned instead of PyHole
>>> from pyhole.jsoned import PyHoleJsoned
the pyhole api is the same, only on every post() and get() data will be json.loads().
It is very easy to create a custom wrapper, like e.g. PyHoleYamled. The only thing is to inherit from PyHole and override method
Hook for processing response with custom function (e.g. yaml.load). Possibly you want to inherit and override this method
The source code of PyHoleYamled is as simple as that:
from pyhole import PyHole
import yaml
class PyHoleYamled(PyHole):
'''PyHole support for yaml that process every response with yaml.load function'''
def get_response_wrapper(self):
return yaml.load
By default PyHole accepts and sends cookies. Cookies are stored only for subsequent calls on the same proxy object.