Methods not found on external-facing API that are declared on an implemented interface

Bug #512828 reported by Julian Edwards
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lazr.restful
Triaged
High
Unassigned

Bug Description

Specifically, in Launchpad there's an interface that's declared like so:

{{{
class IPublishingEdit(Interface):
    """Base interface for writeable Publishing classes."""
    export_as_webservice_entry()

    @call_with(removed_by=REQUEST_USER)
    @operation_parameters(
        removal_comment=TextLine(title=_("Removal comment"), required=False))
    @export_write_operation()
    def requestDeletion(removed_by, removal_comment=None):
...
}}}

This interface is implemented like this:

{{{
class SourcePackagePublishingHistory(SQLBase, ArchivePublisherBase):
    implements(ISourcePackagePublishingHistory, IPublishingEdit)
}}}

However, only the items exported on ISourcePackagePublishingHistory can be seen when accessing the service via launchpadlib.

Changed in lazr.restful:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Leonard Richardson (leonardr) wrote :

When the WADL is generated we go through all the interfaces that have @export_as_webservice_entry, and create a resource_type stanza for each one. You have two such interfaces, ISourcePackagePublishingHistory and IPublishingEdit, so your WADL contains two resource types: source_package_publishing_history and publishing_edit. publishing_edit is the one that defines requestDeletion, and in the WADL it serves no purpose but to confuse people. The requestDeletion operation is not present in source_package_publishing_history, which is the resource_type of any SourcePackagePublishingHistory you receive from the server, so it's not accessible from launchpadlib.

But, if a request does come in to invoke requestDeletion on an ISourcePackagePublishingHistory, lazr.restful does a multi-adapter lookup on the ISourcePackagePublishingHistory object, which also happens to implement IPublishingEdit. The lookup succeeds and the operation is invoked.

To get this to work as is, we would have to change from iterating over the @export_as_webservice_entry interfaces to iterating over every class that implements one or more @export_as_webservice_entry interfaces. I'm not sure how to do this but it doesn't sound like a bad idea--it would remove has_bugs and has_milestones from Launchpad's WADL, more resource types that only serve to confuse people. But it's a pretty major project that I don't want to undertake now, especially since you can fix this problem by making ISourcePackagePublishingHistory subclass IPublishingEdit and removing @export_as_webservice_entry from IPublishingEdit.

Incidentally, according to our web service publishing standards the name of the named operation should be request_deletion. Use a @export_as() call to give it the right name.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Are this and #342413 duplicates of one another?

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

Yes, or close enough, since salgado is actually making progress on 342413 and I think it would address Julian's request. I'll dupe it.

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

Hm, salgado's work isn't quite the same, is it; but it's a step in the right direction.

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.