howdy jen... great to see you on App Engine!

as far as your problem goes, have you checked to see just what *are*
the IDs of the objects you've stored? you seem to be trying to select
them, but perhaps their values are not what you're expecting (hence
the query failures).

i would just like to see a query that pulls up your data entities then
displays their IDs if 'id' is a property of your object. if you're
just creating and storing them with put, you're taking the default ID
that App Engine assigns, so in these cases, you need to fetch an
entity's key in order to get to its ID... something like this:

bands = Band.gql('')
for band in bands:
    self.response.out.write('<br>%s: %s<p>\n' % (band.key().id_or_name
(), band.band))

let us know what you get!

cheers,
-wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
"Python Fundamentals", Prentice Hall, (c)2009
   http://corepython.com

wesley.j.chun :: [email protected]
developer relations :: google app engine



On Dec 27, 10:33 pm, "Ms. Jen" <[email protected]> wrote:
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.


Reply via email to