named operations on scoped collections fails with "No such operation"

Bug #605869 reported by Edward F. Long Jr.
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lazr.restful
Triaged
Low
Unassigned

Bug Description

When creating a named operation on a ScopedCollection, Invoking the named operation fails with a "No Such Operation" error

When digging into this issue, I noted that self.context inside the CustomOperationResourceMixin class returns an instance of the
ScopedCollection class instead of the instance of the collection itself.. The workaround is to call self.context.collection in the handleCustomGET/POST code. (See diff below)

It seems like this problem could be residing somewhere higher-up in the call chain, although making the below fix doesn't seem to break anything else and doing a normal GET of a ScopedCollection works regardless of having the change(s) noted below:

A workaround can be done in the handleCustomGET/POST methods in the CustomOperationResourceMixin class

--- lazr.restful-0.9.29/src/lazr/restful/_resource.py.orig 2010-07-15 08:29:42.000000000 -0400
+++ lazr.restful-0.9.29/src/lazr/restful/_resource.py 2010-07-15 08:54:52.000000000 -0400
@@ -667,8 +667,13 @@
         :return: The result of the operation: either a string or an
         object that needs to be serialized to JSON.
         """
+ context = self.context
+ if IScopedCollection.providedBy(context):
+ # The 'context' of a ScopedCollection is actually stored in its
+ # collection property.
+ context = self.context.collection
         try:
- operation = getMultiAdapter((self.context, self.request),
+ operation = getMultiAdapter((context, self.request),
                                         IResourceGETOperation,
                                         name=operation_name)
         except ComponentLookupError:
@@ -685,8 +690,13 @@
         :return: The result of the operation: either a string or an
         object that needs to be serialized to JSON.
         """
+ context = self.context
+ if IScopedCollection.providedBy(context):
+ # The 'context' of a ScopedCollection is actually stored in its
+ # collection property.
+ context = self.context.collection
         try:
- operation = getMultiAdapter((self.context, self.request),
+ operation = getMultiAdapter((context, self.request),
                                         IResourcePOSTOperation,
                                         name=operation_name)
         except ComponentLookupError:

Revision history for this message
Gary Poster (gary) wrote :

This looks reasonable to me.

FWIW, if Leonard doesn't object and you gave us a branch with tests, that would make this happen fastest.

Changed in lazr.restful:
status: New → Triaged
importance: Undecided → Low
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.