Hi Frederico,

In the post-call hook, the response variable will be filled in with the RPC
response, which in the case of a Datastore put will be a list of keys of the
stored entities. If you want to step through them in sync with the entities,
this code may prove useful:

  def post_hook(service, call, request, response):
    if call == 'Put':
      for key, entity in zip(response.key_list(), request.entity_list()):
        # Do something with key, entity.

-Nick Johnson

On Fri, Jun 19, 2009 at 7:52 PM, Federico Builes
<[email protected]>wrote:

>
> I'm using a post hook for datastore puts and I'd like to be able to access
> the id of an entity after
> it's saved. Although I can access all the properties of the entity from the
> PB, I don't have any
> idea of how to access the key, and the only relevant document I've found
> (http://code.google.com/appengine/articles/hooks.html) does not really go
> deep enough into the
> subject.
> Any suggestions? Below is the code for the hook I'm using:
>
>    def post_hook(service, call, request, response):
>        if call is "Put":
>            for entity in request.entity_list():
>                # I'd like to get the key of the entity here
>    apiproxy_stub_map.apiproxy.GetPostCallHooks().Append('post_hook',
> post_hook, 'datastore_v3')
>
> --
> Federico Builes
>
> >
>


-- 
Nick Johnson, App Engine Developer Programs Engineer
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number:
368047

--~--~---------~--~----~------------~-------~--~----~
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