Re: Axiom queries involving Powerups

"Calvin Spealman" <[email protected]> Thu, 31 Aug 2006 13:48:11 -0400
Newsgroups gmane.comp.python.quotient.dev
Message-ID <[email protected]>
Basically, you can't do joins between item types, which is what this
would boil down to in the SQL code. It hasn't been implemented that
last I looked, but maybe way down the road we will see it. This is
along the lines that you can't query for an attribute of a referenced
item.

It could be potentially expensive, because for every row of the item
found (not using the powerup condition), you then have to search the
powerup connectors, join them with the items and the powerups, which
you also have to get. As I have seen, it might happen one day, but
that day isn't in sight.

If anything I'm saying is out of date, someone correct me.

On 8/31/06, Robert Gravina <[email protected]> wrote:
> I am trying to do a query for an Item that checks the value of an
> attribute which belongs it's powerup.
>
> Sorry about not generalising the example... but in the snippet that
> follows straight out of my code:
>         Lead is an Item subclass, and so is "self", which an an object
> instance (also an Item) doing the querying in one of it's methods
>         IRecyclable is the powerup interface, and Lead installs it on in
> it's __init__ method. It only has one boolean attribute "inRecycleBin".
>
> I tried this:
>         list(self.store.query(Lead,AND(Lead.pipeline == self,
> IRecyclable(Lead).inRecycleBin == False)))
>
> which gives me an error:
>            File "/Library/Frameworks/Python.framework/Versions/2.4/
> lib/python2.4/site-packages/zope/interface/interface.py", line 682,
> in __call__
>              raise TypeError("Could not adapt", obj, self)
>          exceptions.TypeError: ('Could not adapt', <class
> 'salespipeline.model.Lead'>, <InterfaceClass
> salespipeline.model.IRecyclable>)
>
> I suppose it's expecting an instance, not the class? Is there anyway
> to do this kind of query?
>
> I found a workaround however... this works;
>         [l for l in list(self.store.query(Lead,Lead.pipeline ==
> self)) if IRecyclable(l).inRecycleBin == False]
>
> But I'm not sure if this is a good way of going about it. I was
> wondering if I'm doing something obviously wrong here?
>
> Thanks!
>
> Robert
>
> _______________________________________________
> Divmod-dev mailing list
> [email protected]
> http://divmod.org/users/mailman.twistd/listinfo/divmod-dev
>