Merge lp:~leonardr/lazr.restfulclient/delete-entry into lp:lazr.restfulclient

Proposed by Leonard Richardson
Status: Merged
Approved by: Aaron Bentley
Approved revision: 101
Merged at revision: not available
Proposed branch: lp:~leonardr/lazr.restfulclient/delete-entry
Merge into: lp:lazr.restfulclient
Diff against target: 81 lines (+34/-1)
4 files modified
src/lazr/restfulclient/NEWS.txt (+4/-1)
src/lazr/restfulclient/_browser.py (+1/-0)
src/lazr/restfulclient/docs/entries.txt (+25/-0)
src/lazr/restfulclient/resource.py (+4/-0)
To merge this branch: bzr merge lp:~leonardr/lazr.restfulclient/delete-entry
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+24421@code.launchpad.net

Description of the change

This branch rectifies a major oversight: there was no non-hacky way to DELETE a lazr.restful entry resource from lazr.restfulclient.

To get the tests to work I had to create
https://code.edge.launchpad.net/~leonardr/lazr.restful/fix-remove-recipe.

To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

Oh: I originally wanted to implement __del__ instead of lp_delete, but upon reading the documentation I saw that __del__ deletes the _variable_ assignment, not necessarily the underlying object. So it's not an appropriate overload.

Revision history for this message
Leonard Richardson (leonardr) wrote :

The fix-remove-recipe branch seems not to be necessary--there was an intermittent problem with my setup that's now gone away.

Revision history for this message
Leonard Richardson (leonardr) wrote :
Revision history for this message
Aaron Bentley (abentley) :
review: Approve
102. By Leonard Richardson

Updated release date.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/lazr/restfulclient/NEWS.txt'
--- src/lazr/restfulclient/NEWS.txt 2010-04-27 19:18:57 +0000
+++ src/lazr/restfulclient/NEWS.txt 2010-05-03 16:45:39 +0000
@@ -2,13 +2,16 @@
2NEWS for lazr.restfulclient2NEWS for lazr.restfulclient
3===========================3===========================
44
50.9.16 (2010-04-27)50.9.16 (2010-05-03)
6===================6===================
77
8 - If a server returns a 502 or 503 error code, lazr.restfulclient8 - If a server returns a 502 or 503 error code, lazr.restfulclient
9 will retry its request a configurable number of times in hopes that9 will retry its request a configurable number of times in hopes that
10 the error is transient.10 the error is transient.
1111
12 - It's now possible to invoke lazr.restful destructor methods, with
13 the lp_delete() method.
14
120.9.15 (2010-04-27)150.9.15 (2010-04-27)
13====================16====================
1417
1518
=== modified file 'src/lazr/restfulclient/_browser.py'
--- src/lazr/restfulclient/_browser.py 2010-04-29 13:17:40 +0000
+++ src/lazr/restfulclient/_browser.py 2010-05-03 16:45:39 +0000
@@ -355,6 +355,7 @@
355 def delete(self, url):355 def delete(self, url):
356 """DELETE the resource at the given URL."""356 """DELETE the resource at the given URL."""
357 self._request(url, method='DELETE')357 self._request(url, method='DELETE')
358 return None
358359
359 def patch(self, url, representation, headers=None):360 def patch(self, url, representation, headers=None):
360 """PATCH the object at url with the updated representation."""361 """PATCH the object at url with the updated representation."""
361362
=== modified file 'src/lazr/restfulclient/docs/entries.txt'
--- src/lazr/restfulclient/docs/entries.txt 2010-04-14 19:02:48 +0000
+++ src/lazr/restfulclient/docs/entries.txt 2010-05-03 16:45:39 +0000
@@ -469,3 +469,28 @@
469 ...469 ...
470 ValueError: You tried to access a resource that you don't have the470 ValueError: You tried to access a resource that you don't have the
471 server-side permission to see.471 server-side permission to see.
472
473Deleting an entry
474=================
475
476Some entries can be deleted with the lp_delete method.
477
478 >>> recipe = service.recipes[6]
479 >>> print recipe.lp_delete()
480 None
481
482A deleted entry no longer exists.
483
484 >>> recipe.lp_refresh()
485 Traceback (most recent call last):
486 ...
487 HTTPError: HTTP Error 404: Not Found
488 ...
489
490Some entries can't be deleted.
491
492 >>> cookbook.lp_delete()
493 Traceback (most recent call last):
494 ...
495 HTTPError: HTTP Error 405: Method Not Allowed
496 ...
472497
=== modified file 'src/lazr/restfulclient/resource.py'
--- src/lazr/restfulclient/resource.py 2010-04-27 19:16:14 +0000
+++ src/lazr/restfulclient/resource.py 2010-05-03 16:45:39 +0000
@@ -609,6 +609,10 @@
609 return '<%s at %s>' % (609 return '<%s at %s>' % (
610 URI(self.resource_type_link).fragment, self.self_link)610 URI(self.resource_type_link).fragment, self.self_link)
611611
612 def lp_delete(self):
613 """Delete the resource."""
614 return self._root._browser.delete(URI(self.self_link))
615
612 def __str__(self):616 def __str__(self):
613 """Return the URL to the resource."""617 """Return the URL to the resource."""
614 return self.self_link618 return self.self_link

Subscribers

People subscribed via source and target branches