[google-appengine] Need help with a query...

2010-03-13 Thread Patrick Twohig
So, the business requirements of my application need a query which needs to
search for a property (let's call it foo) and a date property such that it
will filter out all objects older than a certain date.  I guess in GAE/J
this would be something like

Query q =  new Query(MyKind)
.addFilter(foo, GREATER_THAN, 0)
.addFilter(bar, LESS_THAN, 42)
.addFilter(date, GREATER_THAN, someDate);

But, I'm guessing that wouldn't work because it's got inequality filters on
multiple properties.  Would there be a way to get a similar result without
loading a huge amount of entities into memory and filtering them out
manually?


-- 
Patrick H. Twohig.

Namazu Studios
P.O. Box 34161
San Diego, CA 92163-4161

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] Need Help with Datastore Query

2009-12-27 Thread Ms. Jen
Hello All(),

I have been struggling with attempting to run a datastore query and
keep getting the same error even though I have read through all the
docs on Queries and Keys, watching several of the Google I/O videos,
as well as looking at a number other apps' source code to see how they
are done.

The error I get is:

Traceback (most recent call last):
  File /Applications/GoogleAppEngineLauncher.app/Contents/Resources/
GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/
google/appengine/ext/webapp/__init__.py, line 507, in __call__
handler.get(*groups)
  File /Users/msjen/Dev/alex/alexsbarbooking/editband.py, line 41,
in get
self._displayEditBandPage()
  File /Users/msjen/Dev/alex/alexsbarbooking/editband.py, line 32,
in _displayEditBandPage
raise ValueError, 'Band with ID %d does not exist.' % id
ValueError: Band with ID 2 does not exist.

My code is:
id = int(self.request.get('id'))
band_id = Band.get(db.Key.from_path('Band', id))
if band_id:
  band_query = Band.gql(WHERE ID = , id)
  band = band_query.fetch(1)
  self.response.out.write('Band query successful. %s : %d' %
band.band_name, id)
  if not band_edit:
raise ValueError, 'Band query with ID %d did not get the info
from the datastore.' % id
if not band_id:
  raise ValueError, 'Band with ID %d does not exist.' % id

I have imported the db.model of band:
from band import Band

The other error I get if I use other code samples is that the global
variable of 'band' is not recognized, even though I have imported the
model.

the URL path that I am requesting the id from is: 
http://localhost:8080/editband/?id=2
And I am able to run a self.write.reponse to write out the requested
id from the path.

The problem seems to lie in passing the requested path id into the
query where I want to filter it by the requested id.

Please, please, tell me that another set of eyes can spot what I am
doing wrong here

Thanks in advance,
Jen

--

You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.