I believe that a Gcl query cannot incorporate calls to accessor methods or attribute extraction (much in the same vein as the fact it can only do "SELECT * FROM"
to fetch whole entities or "SELECT __key__ FROM"
to fetch keys only -- it cannot pick and choose fields as in [hypothetical!-)] "SELECT this, that FROM
").
So, you need to fetch the keys, then call each key's .id()
accessor (if you want None
for keys that don't have an ID but rather a name; use .id_or_name()
if you'd rather get the name, if available, and None
only as a last resort). E.g., to get non-None IDs only:
thekeys = db.GqlQuery('SELECT __key__ FROM Whatever').fetch(1000)
theids = [k.id() for k in thekeys if k.id() is not None]