The "default=[]" is causing this. All instances share the same list object 
this way. You'll have to find some other way of initializing the value. 
Maybe you cna just use a repeated string property?

On Saturday, July 28, 2012 11:56:46 AM UTC-7, Robert Fischer wrote:
>
> Hi,
>
> I'm creating a new instance of a model and it's getting the data from the 
> previous model I created.
>
> Any idea what could be happening here?
>
> class Keyword(ndb.Model):
>     user_owner = ndb.UserProperty()
>     description = ndb.StringProperty(indexed=False)
>     time_created = ndb.DateTimeProperty(auto_now_add=True, indexed=False)
>     deleted = ndb.BooleanProperty(default=False)
>     keyword_list = ndb.StringProperty(repeated=True, indexed=True) #Indexed
>     required_keyword_list = ndb.StringProperty(repeated=True, 
> indexed=False)
>
>     threshold = ndb.IntegerProperty(indexed=False)
>
>      last_found_on_id = ndb.StringProperty(indexed=False)
>     ids_found_on = ndb.JsonProperty(default=[], indexed=False)
>     times_found = ndb.ComputedProperty(lambda self: 
> len(self.ids_found_on)) #Indexed
>     time_last_found = ndb.DateTimeProperty(indexed=False)
>
> class KeywordHandler(webapp2.RequestHandler)
>     def post(self):
>         ...
>         logging.warning('Creating new keyword object.')
>         keyword_to_save = Keyword()
>         logging.warning('ids associated with keyword: %s %s %s' % 
> (str(keyword_to_save.key), str(keyword_to_save), 
> keyword_to_save.ids_found_on))
>         ... 
>
> The first time I run this it works great:
> WARNING  2012-07-28 18:27:32,403 frontend_keywords.py:176] ids associated 
> with keyword: None Keyword() []
>
> When run a second time I get this in my log file -- why is the 
> ids_found_on already populated for a new model instance? The ids_found_on 
> matches the previously created entity:
>
> WARNING  2012-07-28 18:27:40,459 frontend_keywords.py:176] ids associated 
> with keyword: None Keyword() 
> ['ahBkZXZ-ZGVhbHNjb3JjaGVyciwLEghSU1NFbnRyeSIeMjAxMi0wNy0yNCAxMzo0NTozOC1zeW1hbnRlYyBuDA',
>  
> 'ahBkZXZ-ZGVhbHNjb3JjaGVyciwLEghSU1NFbnRyeSIeMjAxMi0wNy0yNCAxNjozNDo0Ni1kb2xpY2EgcHJvDA',
>  
> 'ah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-ZGVhbHNjb3JjaGVyciwLEghSU1NFbnRyeSIeMjAxMi0wNy0yNiAxNzo1NDoyOC00MSB2b3JuYWRvDA',
>  
> 'ahBkZXZ-ZGVhbHNjb3JjaGVyciwLEghSU1NFbnRyeSIeMjAxMi0wNy0yNiAxODowNDoyOC1sb2dpdGVjaCBoDA']
>
> Thanks,
> Robert
>

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