Difficult to use for arbitrary URLs

Bug #1041825 reported by Jonathan Lange
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
piston-mini-client
Triaged
Undecided
Unassigned

Bug Description

piston_mini_client is great for implementing multiple methods against a single service. However, there are cases where we want to do almost everything that piston_mini_client does, but without the service_root + '/' + path logic: we just want to hit a URL with some method and some data.

To do that at the moment, one has to write something like this::

    class SingleURLAPI(PistonAPI):

        def __init__(self, url, auth=None, disable_ssl_validation=False,
                     log_filename=None, timeout=None):
            super(SingleURLAPI, self).__init__(
                service_root=url, cachedir=None, auth=auth,
                disable_ssl_validation=disable_ssl_validation,
                log_filename=log_filename, timeout=timeout)

        def _path2url(self, path, scheme):
            # We don't want the service_root + '/' + path behaviour.
            return self._service_root

        def put(self, data):
            return self._put(None, data)

I suggest that piston_mini_client extracts most of PistonAPI into a separate class, say PistonRequest, that implements public methods for each request method type and does what _put, _get, etc. do now. Then PistonAPI can be a class intended to be subclassed for API definitions.

Related branches

Revision history for this message
Jonathan Lange (jml) wrote :

The linked branch is a rough sketch of what I mean.

Jonathan Lange (jml)
Changed in piston-mini-client:
status: New → In Progress
assignee: nobody → Jonathan Lange (jml)
Revision history for this message
Jonathan Lange (jml) wrote :

I can't recall whether this is done.

I've discovered requests <http://requests.readthedocs.org/en/latest/> & treq <http://treq.readthedocs.org/en/latest/>, and will probably be using those instead of p-m-c in future, as they are closer to my needs.

Changed in piston-mini-client:
status: In Progress → Triaged
assignee: Jonathan Lange (jml) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.