Axiom queries involving Powerups
Robert Gravina <[email protected]> Thu, 31 Aug 2006 18:35:04 +0900
| Newsgroups | gmane.comp.python.quotient.dev |
|---|---|
| Message-ID | <[email protected]> |
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