Matt,

sorry for the delay.  Since i don't have use for the key queries yet i'm 
gonna ask you to try something, and then we can ask massimo to include 
it....

* grab the latest web2py source from trunk, i have mercurial commit #1572 
* in gluon/dal,py find line 2697.  it should look like:
            elif filter.name=='__key__' and filter.op=='=':
                if filter.value==0:
                    items = []
                else:
                    item = tableobj.get_by_id(filter.value)
                    items = (item and [item]) or []
* edit the if block method.  this if for GAE only to:
            elif filter.name=='__key__' and filter.op=='=':
                if filter.value==0:
                    items = []
                elif isinstance(filter.value, Key):
                    items = tableobj.get(filter.value)
                else:
                    item = tableobj.get_by_id(filter.value)
                    items = (item and [item]) or []
* test this.  if it works you are done.
* if it did not work, find line 2600:
    def EQ(self,first,second=None):
        return [GAEF(first.name,'=',self.represent(second,first.type),lambda 
a,b:a==b)
* edit the EQ method:
    def EQ(self,first,second=None):
        if isinstance(second, Key):
            return [GAEF(first.name,'=',second,lambda a,b:a==b)
        return [GAEF(first.name,'=',self.represent(second,first.type),lambda 
a,b:a==b)

what does this do? you ask....well, the first edit finds the spot where the 
GQL Query object is created.  if you are doing a key query (based on ID), 
and the operator is '=' you are adding in a check that if the value you are 
filtering is a Key (instead of a long) then do a key query on the Model.  in 
the edit of the EQ method, you are allowing the pass of a raw key to the 
filter creation, so that when the query is run the code that you wrote in 
select_raw() runs.

once you make the edits you should be able to construct a GQL Key object and 
then do db(db.table.id==myGQLKeyObject).select().

give it a try and let me know if it works.  like i said, since i don't have 
a model like yours i don't have a way to test it, please be patient with my 
typos and other things.

christian

Reply via email to