not a good option in my case.

On Mar 27, 2012, at 5:23 PM, Guido van Rossum wrote:

> You might be able to use get_or_insert() and benefit from the in-memory cache.
> 
> On Tue, Mar 27, 2012 at 13:49, Andreas <a.schmi...@gmail.com> wrote:
>> exactly what im doing. i create the keys myself.
>> 
>> rootkey = ndb.Key('root', 'key')
>> a = Asset(key=ndb.Key('Asset', 'keyname', parent=rootkey))
>> 
>> a._has_complete_key() # returns true
>> 
>> in my app i work in with entity batches and sometimes it happens that i need
>> to create ancestors for that entity which could already exist so till now i
>> used is_saved() to filter out the entities that are already saved to the
>> datastore to avoid putting them again (or at least trying to put them again)
>> 
>> 
>> On Mar 27, 2012, at 3:38 PM, Guido van Rossum wrote:
>> 
>> On Tuesday, March 27, 2012 6:41:25 AM UTC-7, aschmid wrote:
>>> 
>>> is there an equivalent of the db.Model function is_saved() with ndb.Model?
>> 
>> 
>> No; what are you trying to do? You might be able to check whether the entity
>> has a key and if so, whether that key isn't incomplete:
>> 
>> if ent.key and ent.key.id():
>>   # It has a complete key.
>> else:
>>   # Hasn't been written, ever.
>> 
>> However this can be fooled if you explicitly set the key or the id when you
>> create an entity, e.g.
>> 
>> ent = Employee(id='joe')
>> 
>> or
>> 
>> ent = Employee(key=ndb.Key(Employee, 'joe'))
>> 
>> (These two are equivalent.)
>> 
>> --Guido van Rossum
>> 
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/google-appengine/-/MeORtJLdaqEJ.
>> 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.
>> 
>> 
>> --
>> 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.
> 
> 
> 
> -- 
> --Guido van Rossum (python.org/~guido)
> 
> -- 
> 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.
> 

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

Reply via email to