Merge lp://staging/~jml/piston-mini-client/split-request-base-1041825 into lp://staging/piston-mini-client

Proposed by Jonathan Lange
Status: Merged
Approved by: Anthony Lenton
Approved revision: 81
Merged at revision: 64
Proposed branch: lp://staging/~jml/piston-mini-client/split-request-base-1041825
Merge into: lp://staging/piston-mini-client
Diff against target: 778 lines (+444/-184)
4 files modified
piston_mini_client/__init__.py (+427/-182)
piston_mini_client/tests/test_failhandlers.py (+15/-0)
piston_mini_client/tests/test_log_to_file.py (+1/-1)
setup.py (+1/-1)
To merge this branch: bzr merge lp://staging/~jml/piston-mini-client/split-request-base-1041825
Reviewer Review Type Date Requested Status
Anthony Lenton Approve
Review via email: mp+124464@code.staging.launchpad.net

Commit message

Add PistonRequester, enabling access to piston_mini_client functionality on a URL-by-URL basis

Description of the change

PistonAPI does two really useful things:
  1. It makes it really easy to define a Python front-end for an HTTP API
  2. It has a bunch of stuff to make doing HTTP requests easier

Sometimes, especially with callback services like pkgme-service, it would be really really useful to do 2. without doing 1. If you take a look at pkgme-service, you'll see code written by the original author (hello achuni!) that duplicates stuff going on in piston-mini-client.

This branch extracts that core, requesting logic into a base class and make PistonAPI subclass it. The base class is called PistonRequester (better names welcome).

Backwards compatibility has been preserved. Everything that subclasses PistonAPI today should still work after this change lands.

I've also changed setup.py to use setuptools, so I could run tox in a virtualenv.

Thanks,
jml

To post a comment you must log in.
69. By Jonathan Lange

Update docstring.

70. By Jonathan Lange

Scheme not needed in PistonRequester methods.

71. By Jonathan Lange

Give the full URL in errors, not just the service root.

72. By Jonathan Lange

Don't have special timeout handling logic. Just take parameters.

73. By Jonathan Lange

As few class variables as we can get away with.

74. By Jonathan Lange

Don't do special log_filename consulting in PistonRequester.

75. By Jonathan Lange

Use PistonRequester, rather than subclass it.

76. By Jonathan Lange

Make all the rest of the attributes private.

77. By Jonathan Lange

Issue deprecation warnings.

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

On 2012-09-14::

16:48:19 <achuni> jml: I thought PistonAPI was going to use PistonRequester as a client in the end?
16:48:33 <achuni> (or did we agree to go the other way around in the end?)
16:48:59 <jml> achuni: you mean, use composition instead of inheritance?
16:49:04 <achuni> yep
16:49:51 <jml> achuni: I'd be very happy to do that. It'll mean potentially breaking backwards compat w/ existing PistonAPI users
16:50:21 <jml> achuni: or alternatively wrapping every existing method (e.g. _prepare_headers, _get_proxy_info, ...)
16:50:25 <achuni> jml: even if you leave the current _get / _post / ... methods there?
16:50:35 <achuni> ah, right
16:50:36 <achuni> hm
16:50:39 <jml> achuni: your call.
16:51:38 <achuni> jml: yep, we'd need to wrap all methods, I think... I'd say the wrappers can be deprecated immediately
16:52:23 <jml> achuni: want warnings for the deprecations, or are docstrings enough?
16:52:52 <achuni> jml: like PistonSerializable._as_serializable... I'm not sure that's the recommended way, but it's what was done last time
16:53:11 <jml> achuni: cool. I'll do that then.

I've now done this. I haven't cleared up the deprecation warnings in the tests.

78. By Jonathan Lange

Rename to DEPRECATED_ATTRIBUTES

79. By Jonathan Lange

Update deprecation message.

80. By Jonathan Lange

Don't emit deprecation warnings on the public attributes

81. By Jonathan Lange

Fix a forwarding bug.

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

I'm pretty sure that this version has addressed all concerns. I'd be glad to see it land.

Revision history for this message
Anthony Lenton (elachuni) wrote :

Thanks jml!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches