My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
  Advanced search   Search tips   Subscriptions
Issue 9098: assigning empty list to StringListProperty with default value results in entity having default value
2 people starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----

Sign in to add a comment
Reported by, Apr 2, 2013
I am Python 2.5. I've pasted a working code example (can be run in the interactive console).

Also raised S/O question:

Is this expected? If so:

1) please show where this is explained in the GAE documentation (or update docs to reflect).

2) please show a pattern for a db.Model that defaults to a populated list for some property at the moment of creation, but still allows us to assign the empty list (or None) at a later moment.

Otherwise, it's a bug :-) For me it's critical because I use list properties to manage user email subscriptions.. so users are unsubscribing from everything and finding that the they are actually getting subscribed to EVERYTHING.

from google.appengine.ext import db

class TestClass(db.Model):
    my_string_list = db.StringListProperty(default=['foo', 'bar'])

instance = TestClass()

print instance.my_string_list
#['foo', 'bar']

instance.my_string_list = []
print instance.my_string_list

instance2 = db.get(instance.key())
print instance2.my_string_list
#expected [], got ['foo', 'bar'] ???
Sign in to add a comment

Powered by Google Project Hosting