The relevant part of the code:
pk = int(pk)
logging.info('pk: %r :: %s', pk, type(pk))
instance = models.Model.get_by_id(int(pk))
The output from the log message above
pk: 757347 :: <type 'int'>
The stacktrace:
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 634, in __call__
handler.get(*groups)
File "/base/data/home/apps/<myapp>/<version>/scrape.py", line 61, in get
instance = models.Model.get_by_id(int(pk))
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 1212, in get_by_id
return get(keys[0], config=config)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 1434, in get
model = cls1.from_entity(entity)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 1350, in from_entity
instance = cls(None, _from_entity=True, **entity_values)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 890, in __init__
prop.__set__(self, value)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 593, in __set__
value = self.validate(value)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 2967, in validate
% (self.name, type(value).__name__))
BadValueError: Property pk must be an int or long, not a unicode
Anyone has an idea if I’m doing something wrong here?
Note: removing the int from the last line of the code makes no difference (that was the first version).
Also, the code works without a problem on dev_appserver.py.
Does your model have a property ‘pk’, which is now an IntegerProperty(), but was previously a StringProperty(), and the entity with id 757347 was saved with the old version of the model?