Merge lp://staging/~thekorn/wadllib/fix-340935-use-actual-type into lp://staging/~launchpad-pqm/wadllib/devel

Proposed by Markus Korn
Status: Rejected
Rejected by: Francis J. Lacoste
Proposed branch: lp://staging/~thekorn/wadllib/fix-340935-use-actual-type
Merge into: lp://staging/~launchpad-pqm/wadllib/devel
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~thekorn/wadllib/fix-340935-use-actual-type
Reviewer Review Type Date Requested Status
Leonard Richardson (community) Disapprove
Launchpad PQM Bot Pending
Review via email: mp+4484@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Markus Korn (thekorn) wrote :

Make sure to always bind a resource to its actual resource type

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

Unfortunately this branch makes the Launchpad-specific assumption that the resource type is kept in "resource_type_link". Launchpad-specific assumptions must go in launchpadlib so that wadllib can stay generic.

I can see a setup where wadllib calls a hook method and passes in the processed representation, and launchpadlib acts as an oracle to determine what the resource type is. Unfortunately I don't have time to do the design in more detail than that.

review: Disapprove

Unmerged revisions

8. By Markus Korn

* wadllib/application.py: Make sure to always bind a resource to its actual
  resource type (LP: #340935)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'wadllib/application.py'
2--- wadllib/application.py 2009-01-23 15:59:00 +0000
3+++ wadllib/application.py 2009-03-14 10:32:42 +0000
4@@ -328,6 +328,16 @@
5 resource.
6 :return: A Resource bound to a particular representation.
7 """
8+ # representation might possibly already be a dict
9+ try:
10+ document = simplejson.loads(representation)
11+ except TypeError:
12+ document = representation
13+ # make sure to always bind a resource to its actual type
14+ resource_type_link = document.get("resource_type_link", None)
15+ if resource_type_link is not None:
16+ resource_type = self.application.get_resource_type(resource_type_link)
17+ self.tag = resource_type.tag
18 return Resource(self.application, self.url, self.tag,
19 representation, media_type,
20 representation_needs_processing,

Subscribers

People subscribed via source and target branches