Hi,
I would like to mention before hand that I am a novice to python and with that to python platform of GAE. I have been finding this very strange error/fault when I am trying to get an entity using its key ID... Here's what I do,
I am querying the datastore entity model UserDetails for the key corresponding to the user name retrieved from UI.
src_key_str = db.GqlQuery('SELECT __key__ FROM UserDetails WHERE user_name = :uname', uname = src_username).fetch(1)
for itr1 in src_key_str:
src_key = itr1.id_or_name()
Then using the src_key
obtained I try to get the entity corresponding to the same.
accounts = UserDetails.get_by_id(src_key)
Now here when I try to access the properties of accounts using self.response.out.write(accounts.user_name)
, I get an error AttributeError: 'list' object has no attribute 'user_name'
. Thinking that accounts was actually a list, I tried to get the first element using accounts[0]
Now I get list out of bound error
.
When I try hard-coding the src_key value, it works just fine but, when I pass the value to the same method I get those errors. I fail to understand why GAE behaves so in production environment and development environment. Am I missing some info on this behaviour?
EDIT : adding stack trace,
Traceback (most recent call last):
File "/base/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 507, in __call__
handler.get(*groups)
File "/base/data/home/apps/bulkloader160by2/1-5.337673425692960489/new_main.py", line 93, in get
self.response.out.write(accounts.user_name)
AttributeError: 'list' object has no attribute 'user_name'