Error caused by binding to anonymous collection resource
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
wadllib |
New
|
Undecided
|
Unassigned |
Bug Description
I think I've found a bug in either wadllib or lazr.restfulclient.
Consider this:
<wadl:method id="person-getBugs" name="GET">
<wadl:request>
<wadl:param style="query" name="ws.op" required="true"
</
<wadl:
</
</wadl:method>
which defines a getBugs method that returns an anonymous collection of
bugs.
<wadl:
<wadl:method name="GET" id="bugs-
<
<
</wadl:method>
</wadl:
<wadl:
<wadl:param style="plain" name="resource_
<wadl:link/>
</wadl:param>
<wadl:param style="plain" name="total_size" path="$
<wadl:param style="plain" name="start" path="$['start']"
<wadl:param style="plain" name="next_
<wadl:link resource_
</wadl:param>
<wadl:param style="plain" name="prev_
path="$
<wadl:link resource_
</wadl:param>
<wadl:param style="plain" name="entries" path="$['entries']"
required="true"/>
<wadl:param style="plain" name="entry_links"
<wadl:link resource_
</wadl:param>
</wadl:
p
which defines the resource type and representation for the bugs
collection.
Note that the method doesn't reference the resource type.
When lazr.restfulclient makes this request it will check to see if the
response contains 'self_link', which it won't in this case. When it
isn't present it creates a WadlResource bound to the representation
declared in the wadl:response, namely bugs-page.
Now, when you go to resolve an attribute of that collection, total_size
say, it will call get_parameter on this created WadlResource, with an
explicit media_type. This will then call
_find_
which states:
If this resource is bound to a representation, the most
appropriate definition is the definition of that
representa
the definition of the representation served in response to a
standard GET.
which is not what the implementation does. If media_type is not None
then it tries to look up the GET representation for that media_type,
which fails as it is not bound to the type.
Is the docstring correct and the code should be changed, or is there
another issue?
I don't have an easy reproducer script unfortunately.
Thanks,
James
Oh, here's a reproducer:
lp.me. getBranches( ).total_ size
Thanks,
James