IMasterObject adaptation doesn't work for native storm model objects

Bug #591841 reported by Julian Edwards
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
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.

Related branches

Revision history for this message
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"
         />

Revision history for this message
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
Revision history for this message
Julian Edwards (julian-edwards) wrote :

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

Revision history for this message
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 :)

Revision history for this message
Stuart Bishop (stub) wrote : Re: [Bug 591841] Re: IMasterObject adaptation doesn't work for native storm model objects

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/

Revision history for this message
Ursula Junque (ursinha) wrote : Bug fixed by a commit
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
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
Stuart Bishop (stub)
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.