You can do it this way:
class Test(db.Model):
pass
class TestHandler(webapp.RequestHandler):
def get(self):
test = Test()
# self.response.out.write(test.key())
# don't do that, it will raise a NotSavedError
test.put()
self.response.out.write(test.key())
# after put(), it works fine. But maybe you need a try...except
2009/4/15 bamkraxler <[email protected]>
>
> I have a form that a user fills out and submits to the datastore.
> Data is inserted using the put() method. After the insert I would
> like to immediately query the datastore and display to the user that
> which was committed. This is fairly standard stuff and is supported
> in various ways (some better than others) in a lot of different
> databases -- been doing it for years. Apparently there is no way to
> do this with the GAE, however, as the key(), though automatically
> generated by the database, is not returned as a property of the
> instance that called the put() method. Is there a way to get the key
> belonging to a put()?
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---