Playing with Google AppEngine (part 1)

So, I’ve been playing around with some CRUD appengine services, and I found something interesting.

Let’s say you have:

class Person(db.Model):
firstname = db.StringProperty()
lastname = db.StringProperty()

and you do something like pass the following dictionary through the POST body:

p = {"firstname":"foo","lastname":"bar"}

then you instantiate a Person as follows (I’m ignoring all data validation for brevity’s sake):

person1 = Person(**p)
result = person1.put()

You can then do:


HOWEVER, once you do:

q = Person.gql('WHERE firstname = :name', name="foo")
result = q.fetch(1)
p = result[0]

You can no longer do p.id().  You have to do p.key().id().  Weird.  Super weird.

1 comment

  1. Brandi says:

    oh man. that is strange. way strange.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>