unicode object has no attribute 'has_key'

123 views
Skip to first unread message

buger

unread,
Apr 17, 2009, 9:04:13 AM4/17/09
to Google App Engine, leon...@gmail.com
When i'm trying to do simple get() it raises error:

Traceback (most recent call last):
File "/base/python_lib/versions/1/google/appengine/ext/webapp/
__init__.py", line 501, in __call__
handler.get(*groups)
File "/base/data/home/apps/musicvideobuger/1.332849534198860778/
video_crawler.py", line 233, in get
videos = Video.all().fetch(100)
File "/base/python_lib/versions/1/google/appengine/ext/db/
__init__.py", line 1391, in fetch
return map(self._model_class.from_entity, raw)
File "/base/python_lib/versions/1/google/appengine/ext/db/
__init__.py", line 997, in from_entity
instance = cls(None, _from_entity=True, **entity_values)
File "/base/python_lib/versions/1/google/appengine/ext/db/
__init__.py", line 596, in __init__
prop.__set__(self, value)
File "/base/python_lib/versions/1/google/appengine/ext/db/
__init__.py", line 2581, in __set__
value = self.validate(value)
File "/base/python_lib/versions/1/google/appengine/ext/db/
__init__.py", line 2611, in validate
if value is not None and not value.has_key():
AttributeError: 'unicode' object has no attribute 'has_key'

It happened after i changed some of properties in model, and i can't
make migration.
Also why get() function checking required option of property? I had
some old data with None values in properties, witch in new version had
been checked as required. When i'm trying to access objects with such
properties with Null values i get error that this property required,
by i'm just trying to get, not put!

Jeff S (Google)

unread,
Apr 20, 2009, 12:38:28 PM4/20/09
to Google App Engine
Hi buger,

Since the kind class has changed, the new validation logic is applied
when loading older objects, as you noticed. I think the simplest way
to get these objects and migrate your data would be to get them using
the old class definition and assign values to the properties which
will be required in the newer version. Another option would be to
manually edit the problematic entities using the admin console's Data
Viewer.

Thank you,

Jeff
Reply all
Reply to author
Forward
0 new messages