IMasterObject adaptation doesn't work for native storm model objects

Bug #591841 reported by Julian Edwards on 2010-06-09
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
High
Stuart Bishop

Bug Description

I have this code:

{{{
    IMasterObject(subscriber).status = ArchiveSubscriberStatus.EXPIRED
}}}

where 'subscriber' is an instance of ArchiveSubscriber, a native Storm class. This code falls over with an error:

*** TypeError: ('could not adapt', <lp.soyuz.model.archivesubscriber.ArchiveSubscriber object at 0x74b1690, <InterfaceClass canonical.launchpad.interfaces.lpstorm.IMasterObject>)

Looking in the zcml it appears that IDBObject is only implemented by SQLBase:

    <class class="canonical.database.sqlbase.SQLBase">
        <implements interface="canonical.launchpad.interfaces.IDBObject" />
    </class>

so I can't adapt native Storm objects in this way.

Stuart Bishop (stub) wrote :

=== modified file 'lib/canonical/launchpad/webapp/configure.zcml'
--- lib/canonical/launchpad/webapp/configure.zcml 2010-06-08 15:57:09 +0000
+++ lib/canonical/launchpad/webapp/configure.zcml 2010-06-10 11:33:24 +0000
@@ -633,7 +633,7 @@
         />
     <adapter
         provides="canonical.launchpad.interfaces.IMasterObject"
- for="canonical.launchpad.interfaces.IDBObject"
+ for="zope.interface.Interface"
         trusted="yes"
         factory="canonical.launchpad.webapp.adapter.get_object_from_master_store"
         />

Gary Poster (gary) wrote :

Stub's suggestion is pragmatic if not precise. I'm OK with it.

Is there a root Storm class (not interface) we can use instead? IIRC, that should work as well. If it doesn't, we can use zcml to slam an interface on the root Storm class, and make the adapter work off of that interface.

Changed in launchpad-foundations:
status: New → Triaged
importance: Undecided → High
Julian Edwards (julian-edwards) wrote :

My Storm classes always inherit from storm.locals.Storm, but I don't know if that's strictly necessary.

Julian Edwards (julian-edwards) wrote :

I'll make this change later today, where's a good place to unit test this? I don't want to clutter that lovely db-policy.txt doctest :)

On Thu, Jun 10, 2010 at 8:10 PM, Gary Poster <email address hidden> wrote:
> Stub's suggestion is pragmatic if not precise.  I'm OK with it.
>
> Is there a root Storm class (not interface) we can use instead?  IIRC,
> that should work as well.  If it doesn't, we can use zcml to slam an
> interface on the root Storm class, and make the adapter work off of that
> interface.

Last time I tried I couldn't do it. There appears to be no way to say
that the Storm and all its subclasses implements an Interface.

--
Stuart Bishop <email address hidden>
http://www.stuartbishop.net/

Changed in launchpad-foundations:
assignee: nobody → Stuart Bishop (stub)
milestone: none → 10.08
tags: added: qa-needstesting
Changed in launchpad-foundations:
status: Triaged → Fix Committed
Stuart Bishop (stub) on 2010-08-02
Changed in launchpad-foundations:
status: Fix Committed → Fix Released
tags: added: qa-untestable
removed: qa-needstesting
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers