Re: [google-appengine] Re: EntityProto instance to Model instance?

2010-01-19 Thread Nickolas Daskalou
Ok, cheers Nick.


2010/1/20 Nick Johnson (Google) 

> Hi Nickolas,
>
> On Tue, Jan 19, 2010 at 1:09 AM, Nickolas Daskalou wrote:
>
>> I've managed to get this going, with the help of the comments in this
>> thread and Nick Johnson's blog post (
>> http://blog.notdot.net/2009/11/API-call-hooks-for-fun-and-profit).
>>
>> My hook code now looks like this:
>>
>>
>> def hook(service, call, request, response):
>> assert service == 'datastore_v3'
>> if call == 'Put':
>> for i in range(request.entity_size()):
>> entity_pb = request.mutable_entity(i)
>> entity = db.model_from_protobuf(entity_pb)
>> try:
>> entity.pre_put()
>> entity_pb.CopyFrom(db.model_to_protobuf(entity))
>> except:
>> pass
>>
>> This seems highly inefficient though, because before an entity is put into
>> the Datastore, it's converted from a Model instance to an EntityProto
>> instance, then back to a Model instance and finally back to an EntityProto
>> instance (Model->EntityProto->Model->EntityProto).
>>
>> Google guys, is there a more efficient way to do this?
>>
>
> Monkeypatching the db module to call pre_put in the appropriate place would
> be a better way to do this, though it's subject to breakage as the API
> changes.
>
> -Nick Johnson
>
>
>>
>> 2010/1/18 Nickolas Daskalou 
>>
>> Will do, thanks Andy.
>>>
>>>
>>> 2010/1/18 Andy Freeman 
>>>
  I asked that question wrt db.class_for_kind and was told that it was
 safe to assume that it would always be there.

 I'd guess that model_from_protobuf should be safe as well.

 File a bug requesting that it be added to the documented function
 list.

 On Jan 17, 6:26 pm, Nickolas Daskalou  wrote:
 > Since these are not documented online anywhere, is it possible these
 > functions may change in the future (and hence break my code)?
 >
 > 2010/1/18 Andy Freeman 
 >
 >
 >
 > > Search in google/appengine/ext/db/__init__.py for protobuf
 functions.
 >
 > > On Jan 16, 9:21 pm, Nickolas Daskalou  wrote:
 > > > Does anyone have an answer for this? Google guys?
 >
 > > > 2010/1/15 Kapil Kaisare 
 >
 > > > > As an aside: what is an EntityProto, and is there a link in the
 GAE
 > > > > documentation for it?
 >
 > > > > Regards,
 > > > > Kaisare, Kapil Sadashiv
 >
 > > > > On Fri, Jan 15, 2010 at 09:37, Nickolas Daskalou <
 n...@daskalou.com
 > > >wrote:
 >
 > > > >> How can I convert an EntityProto to a Model instance?
 >
 > > > >> I have a Model method, pre_put(), that I want to call on each
 Model
 > > > >> instance before it's Put into the Datastore, using hooks (eg:
 > > > >>http://code.google.com/appengine/articles/hooks.html).
 >
 > > > >> My hook code looks like this:
 >
 > > > >> def hook(service, call, request, response):
 > > > >> assert service == 'datastore_v3'
 > > > >> if call == 'Put':
 > > > >> for entity in request.entity_list():
 > > > >> entity.pre_put()
 >
 > > > >> When the hook is called and runs, I get this error:
 >
 > > > >> AttributeError: EntityProto instance has no attribute 'pre_put'
 >
 > > > >> Is there any way to convert the entities in
 request.entity_list() to
 > > their
 > > > >> original Models, manipulate them, and then convert them back to
 an
 > > > >> EntityProto instance? Or even better, if the EntityProto
 instances
 > > have
 > > > >> references to the actual Model instances which we can access
 and
 > > manipulate?
 >
 > > > >> --
 > > > >> 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.
 >
 > > > > --
 > > > > 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-appengine@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.-Hidequoted
 > > text -
 >
 > > > - Show quoted text -
 >
 > > --
 > > You received this message because you are subscribed to the Google
 Groups
 > > "Google App Engine" group.
 >

Re: [google-appengine] Re: EntityProto instance to Model instance?

2010-01-19 Thread Nick Johnson (Google)
Hi Nickolas,

On Tue, Jan 19, 2010 at 1:09 AM, Nickolas Daskalou wrote:

> I've managed to get this going, with the help of the comments in this
> thread and Nick Johnson's blog post (
> http://blog.notdot.net/2009/11/API-call-hooks-for-fun-and-profit).
>
> My hook code now looks like this:
>
>
> def hook(service, call, request, response):
> assert service == 'datastore_v3'
> if call == 'Put':
> for i in range(request.entity_size()):
> entity_pb = request.mutable_entity(i)
> entity = db.model_from_protobuf(entity_pb)
> try:
> entity.pre_put()
> entity_pb.CopyFrom(db.model_to_protobuf(entity))
> except:
> pass
>
> This seems highly inefficient though, because before an entity is put into
> the Datastore, it's converted from a Model instance to an EntityProto
> instance, then back to a Model instance and finally back to an EntityProto
> instance (Model->EntityProto->Model->EntityProto).
>
> Google guys, is there a more efficient way to do this?
>

Monkeypatching the db module to call pre_put in the appropriate place would
be a better way to do this, though it's subject to breakage as the API
changes.

-Nick Johnson


>
> 2010/1/18 Nickolas Daskalou 
>
> Will do, thanks Andy.
>>
>>
>> 2010/1/18 Andy Freeman 
>>
>>>  I asked that question wrt db.class_for_kind and was told that it was
>>> safe to assume that it would always be there.
>>>
>>> I'd guess that model_from_protobuf should be safe as well.
>>>
>>> File a bug requesting that it be added to the documented function
>>> list.
>>>
>>> On Jan 17, 6:26 pm, Nickolas Daskalou  wrote:
>>> > Since these are not documented online anywhere, is it possible these
>>> > functions may change in the future (and hence break my code)?
>>> >
>>> > 2010/1/18 Andy Freeman 
>>> >
>>> >
>>> >
>>> > > Search in google/appengine/ext/db/__init__.py for protobuf functions.
>>> >
>>> > > On Jan 16, 9:21 pm, Nickolas Daskalou  wrote:
>>> > > > Does anyone have an answer for this? Google guys?
>>> >
>>> > > > 2010/1/15 Kapil Kaisare 
>>> >
>>> > > > > As an aside: what is an EntityProto, and is there a link in the
>>> GAE
>>> > > > > documentation for it?
>>> >
>>> > > > > Regards,
>>> > > > > Kaisare, Kapil Sadashiv
>>> >
>>> > > > > On Fri, Jan 15, 2010 at 09:37, Nickolas Daskalou <
>>> n...@daskalou.com
>>> > > >wrote:
>>> >
>>> > > > >> How can I convert an EntityProto to a Model instance?
>>> >
>>> > > > >> I have a Model method, pre_put(), that I want to call on each
>>> Model
>>> > > > >> instance before it's Put into the Datastore, using hooks (eg:
>>> > > > >>http://code.google.com/appengine/articles/hooks.html).
>>> >
>>> > > > >> My hook code looks like this:
>>> >
>>> > > > >> def hook(service, call, request, response):
>>> > > > >> assert service == 'datastore_v3'
>>> > > > >> if call == 'Put':
>>> > > > >> for entity in request.entity_list():
>>> > > > >> entity.pre_put()
>>> >
>>> > > > >> When the hook is called and runs, I get this error:
>>> >
>>> > > > >> AttributeError: EntityProto instance has no attribute 'pre_put'
>>> >
>>> > > > >> Is there any way to convert the entities in
>>> request.entity_list() to
>>> > > their
>>> > > > >> original Models, manipulate them, and then convert them back to
>>> an
>>> > > > >> EntityProto instance? Or even better, if the EntityProto
>>> instances
>>> > > have
>>> > > > >> references to the actual Model instances which we can access and
>>> > > manipulate?
>>> >
>>> > > > >> --
>>> > > > >> 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.
>>> >
>>> > > > > --
>>> > > > > 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-appengine@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.-Hidequoted
>>> > > text -
>>> >
>>> > > > - Show quoted text -
>>> >
>>> > > --
>>> > > 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

Re: [google-appengine] Re: EntityProto instance to Model instance?

2010-01-18 Thread Nickolas Daskalou
I've managed to get this going, with the help of the comments in this thread
and Nick Johnson's blog post (
http://blog.notdot.net/2009/11/API-call-hooks-for-fun-and-profit).

My hook code now looks like this:

def hook(service, call, request, response):
assert service == 'datastore_v3'
if call == 'Put':
for i in range(request.entity_size()):
entity_pb = request.mutable_entity(i)
entity = db.model_from_protobuf(entity_pb)
try:
entity.pre_put()
entity_pb.CopyFrom(db.model_to_protobuf(entity))
except:
pass

This seems highly inefficient though, because before an entity is put into
the Datastore, it's converted from a Model instance to an EntityProto
instance, then back to a Model instance and finally back to an EntityProto
instance (Model->EntityProto->Model->EntityProto).

Google guys, is there a more efficient way to do this?


2010/1/18 Nickolas Daskalou 

> Will do, thanks Andy.
>
>
> 2010/1/18 Andy Freeman 
>
>>  I asked that question wrt db.class_for_kind and was told that it was
>> safe to assume that it would always be there.
>>
>> I'd guess that model_from_protobuf should be safe as well.
>>
>> File a bug requesting that it be added to the documented function
>> list.
>>
>> On Jan 17, 6:26 pm, Nickolas Daskalou  wrote:
>> > Since these are not documented online anywhere, is it possible these
>> > functions may change in the future (and hence break my code)?
>> >
>> > 2010/1/18 Andy Freeman 
>> >
>> >
>> >
>> > > Search in google/appengine/ext/db/__init__.py for protobuf functions.
>> >
>> > > On Jan 16, 9:21 pm, Nickolas Daskalou  wrote:
>> > > > Does anyone have an answer for this? Google guys?
>> >
>> > > > 2010/1/15 Kapil Kaisare 
>> >
>> > > > > As an aside: what is an EntityProto, and is there a link in the
>> GAE
>> > > > > documentation for it?
>> >
>> > > > > Regards,
>> > > > > Kaisare, Kapil Sadashiv
>> >
>> > > > > On Fri, Jan 15, 2010 at 09:37, Nickolas Daskalou <
>> n...@daskalou.com
>> > > >wrote:
>> >
>> > > > >> How can I convert an EntityProto to a Model instance?
>> >
>> > > > >> I have a Model method, pre_put(), that I want to call on each
>> Model
>> > > > >> instance before it's Put into the Datastore, using hooks (eg:
>> > > > >>http://code.google.com/appengine/articles/hooks.html).
>> >
>> > > > >> My hook code looks like this:
>> >
>> > > > >> def hook(service, call, request, response):
>> > > > >> assert service == 'datastore_v3'
>> > > > >> if call == 'Put':
>> > > > >> for entity in request.entity_list():
>> > > > >> entity.pre_put()
>> >
>> > > > >> When the hook is called and runs, I get this error:
>> >
>> > > > >> AttributeError: EntityProto instance has no attribute 'pre_put'
>> >
>> > > > >> Is there any way to convert the entities in request.entity_list()
>> to
>> > > their
>> > > > >> original Models, manipulate them, and then convert them back to
>> an
>> > > > >> EntityProto instance? Or even better, if the EntityProto
>> instances
>> > > have
>> > > > >> references to the actual Model instances which we can access and
>> > > manipulate?
>> >
>> > > > >> --
>> > > > >> 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.
>> >
>> > > > > --
>> > > > > 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-appengine@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.-Hide quoted
>> > > text -
>> >
>> > > > - Show quoted text -
>> >
>> > > --
>> > > 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.- Hide quoted
>> text -
>> >
>> > - Show quoted text -
>>
>> --
>> 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

Re: [google-appengine] Re: EntityProto instance to Model instance?

2010-01-17 Thread Nickolas Daskalou
Will do, thanks Andy.


2010/1/18 Andy Freeman 

> I asked that question wrt db.class_for_kind and was told that it was
> safe to assume that it would always be there.
>
> I'd guess that model_from_protobuf should be safe as well.
>
> File a bug requesting that it be added to the documented function
> list.
>
> On Jan 17, 6:26 pm, Nickolas Daskalou  wrote:
> > Since these are not documented online anywhere, is it possible these
> > functions may change in the future (and hence break my code)?
> >
> > 2010/1/18 Andy Freeman 
> >
> >
> >
> > > Search in google/appengine/ext/db/__init__.py for protobuf functions.
> >
> > > On Jan 16, 9:21 pm, Nickolas Daskalou  wrote:
> > > > Does anyone have an answer for this? Google guys?
> >
> > > > 2010/1/15 Kapil Kaisare 
> >
> > > > > As an aside: what is an EntityProto, and is there a link in the GAE
> > > > > documentation for it?
> >
> > > > > Regards,
> > > > > Kaisare, Kapil Sadashiv
> >
> > > > > On Fri, Jan 15, 2010 at 09:37, Nickolas Daskalou <
> n...@daskalou.com
> > > >wrote:
> >
> > > > >> How can I convert an EntityProto to a Model instance?
> >
> > > > >> I have a Model method, pre_put(), that I want to call on each
> Model
> > > > >> instance before it's Put into the Datastore, using hooks (eg:
> > > > >>http://code.google.com/appengine/articles/hooks.html).
> >
> > > > >> My hook code looks like this:
> >
> > > > >> def hook(service, call, request, response):
> > > > >> assert service == 'datastore_v3'
> > > > >> if call == 'Put':
> > > > >> for entity in request.entity_list():
> > > > >> entity.pre_put()
> >
> > > > >> When the hook is called and runs, I get this error:
> >
> > > > >> AttributeError: EntityProto instance has no attribute 'pre_put'
> >
> > > > >> Is there any way to convert the entities in request.entity_list()
> to
> > > their
> > > > >> original Models, manipulate them, and then convert them back to an
> > > > >> EntityProto instance? Or even better, if the EntityProto instances
> > > have
> > > > >> references to the actual Model instances which we can access and
> > > manipulate?
> >
> > > > >> --
> > > > >> 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.
> >
> > > > > --
> > > > > 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-appengine@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.-Hide quoted
> > > text -
> >
> > > > - Show quoted text -
> >
> > > --
> > > 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-appengine@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.- Hide quoted
> text -
> >
> > - Show quoted text -
>
> --
> 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.
>
>
>
>
-- 

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] Re: EntityProto instance to Model instance?

2010-01-17 Thread Andy Freeman
I asked that question wrt db.class_for_kind and was told that it was
safe to assume that it would always be there.

I'd guess that model_from_protobuf should be safe as well.

File a bug requesting that it be added to the documented function
list.

On Jan 17, 6:26 pm, Nickolas Daskalou  wrote:
> Since these are not documented online anywhere, is it possible these
> functions may change in the future (and hence break my code)?
>
> 2010/1/18 Andy Freeman 
>
>
>
> > Search in google/appengine/ext/db/__init__.py for protobuf functions.
>
> > On Jan 16, 9:21 pm, Nickolas Daskalou  wrote:
> > > Does anyone have an answer for this? Google guys?
>
> > > 2010/1/15 Kapil Kaisare 
>
> > > > As an aside: what is an EntityProto, and is there a link in the GAE
> > > > documentation for it?
>
> > > > Regards,
> > > > Kaisare, Kapil Sadashiv
>
> > > > On Fri, Jan 15, 2010 at 09:37, Nickolas Daskalou  > >wrote:
>
> > > >> How can I convert an EntityProto to a Model instance?
>
> > > >> I have a Model method, pre_put(), that I want to call on each Model
> > > >> instance before it's Put into the Datastore, using hooks (eg:
> > > >>http://code.google.com/appengine/articles/hooks.html).
>
> > > >> My hook code looks like this:
>
> > > >> def hook(service, call, request, response):
> > > >>     assert service == 'datastore_v3'
> > > >>     if call == 'Put':
> > > >>         for entity in request.entity_list():
> > > >>             entity.pre_put()
>
> > > >> When the hook is called and runs, I get this error:
>
> > > >> AttributeError: EntityProto instance has no attribute 'pre_put'
>
> > > >> Is there any way to convert the entities in request.entity_list() to
> > their
> > > >> original Models, manipulate them, and then convert them back to an
> > > >> EntityProto instance? Or even better, if the EntityProto instances
> > have
> > > >> references to the actual Model instances which we can access and
> > manipulate?
>
> > > >> --
> > > >> 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.
>
> > > > --
> > > > 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-appengine@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.-Hide quoted
> > text -
>
> > > - Show quoted text -
>
> > --
> > 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.- Hide quoted text -
>
> - Show quoted text -
-- 
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.




Re: [google-appengine] Re: EntityProto instance to Model instance?

2010-01-17 Thread Nickolas Daskalou
Since these are not documented online anywhere, is it possible these
functions may change in the future (and hence break my code)?


2010/1/18 Andy Freeman 

> Search in google/appengine/ext/db/__init__.py for protobuf functions.
>
>
> On Jan 16, 9:21 pm, Nickolas Daskalou  wrote:
> > Does anyone have an answer for this? Google guys?
> >
> > 2010/1/15 Kapil Kaisare 
> >
> >
> >
> > > As an aside: what is an EntityProto, and is there a link in the GAE
> > > documentation for it?
> >
> > > Regards,
> > > Kaisare, Kapil Sadashiv
> >
> > > On Fri, Jan 15, 2010 at 09:37, Nickolas Daskalou  >wrote:
> >
> > >> How can I convert an EntityProto to a Model instance?
> >
> > >> I have a Model method, pre_put(), that I want to call on each Model
> > >> instance before it's Put into the Datastore, using hooks (eg:
> > >>http://code.google.com/appengine/articles/hooks.html).
> >
> > >> My hook code looks like this:
> >
> > >> def hook(service, call, request, response):
> > >> assert service == 'datastore_v3'
> > >> if call == 'Put':
> > >> for entity in request.entity_list():
> > >> entity.pre_put()
> >
> > >> When the hook is called and runs, I get this error:
> >
> > >> AttributeError: EntityProto instance has no attribute 'pre_put'
> >
> > >> Is there any way to convert the entities in request.entity_list() to
> their
> > >> original Models, manipulate them, and then convert them back to an
> > >> EntityProto instance? Or even better, if the EntityProto instances
> have
> > >> references to the actual Model instances which we can access and
> manipulate?
> >
> > >> --
> > >> 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.
> >
> > > --
> > > 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-appengine@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.- Hide quoted
> text -
> >
> > - Show quoted text -
>
> --
> 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.
>
>
>
>
-- 

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] Re: EntityProto instance to Model instance?

2010-01-17 Thread Andy Freeman
Search in google/appengine/ext/db/__init__.py for protobuf functions.


On Jan 16, 9:21 pm, Nickolas Daskalou  wrote:
> Does anyone have an answer for this? Google guys?
>
> 2010/1/15 Kapil Kaisare 
>
>
>
> > As an aside: what is an EntityProto, and is there a link in the GAE
> > documentation for it?
>
> > Regards,
> > Kaisare, Kapil Sadashiv
>
> > On Fri, Jan 15, 2010 at 09:37, Nickolas Daskalou wrote:
>
> >> How can I convert an EntityProto to a Model instance?
>
> >> I have a Model method, pre_put(), that I want to call on each Model
> >> instance before it's Put into the Datastore, using hooks (eg:
> >>http://code.google.com/appengine/articles/hooks.html).
>
> >> My hook code looks like this:
>
> >> def hook(service, call, request, response):
> >>     assert service == 'datastore_v3'
> >>     if call == 'Put':
> >>         for entity in request.entity_list():
> >>             entity.pre_put()
>
> >> When the hook is called and runs, I get this error:
>
> >> AttributeError: EntityProto instance has no attribute 'pre_put'
>
> >> Is there any way to convert the entities in request.entity_list() to their
> >> original Models, manipulate them, and then convert them back to an
> >> EntityProto instance? Or even better, if the EntityProto instances have
> >> references to the actual Model instances which we can access and 
> >> manipulate?
>
> >> --
> >> 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.
>
> > --
> > 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.- Hide quoted text -
>
> - Show quoted text -
-- 
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.