GAE - Getting TypeError requiring class instance be passed to class's own method...
Posted
by Spencer Leland
on Stack Overflow
See other posts from Stack Overflow
or by Spencer Leland
Published on 2010-03-18T02:20:20Z
Indexed on
2010/03/18
2:21 UTC
Read the original article
Hit count: 403
I'm really new to programming... I set up a class to give supporting information for Google's User API user object. I store this info in the datastore using db.model.
When I call the okstatus method of my user_info class using this code:
elif user_info.okstatus(user):
self.response.out.write("user allowed")
I get this error:
unbound method okstatus() must be called with user_info instance
as first argument (got User instance instead)
Here is my user_info class.
class user_info:
def auth_ctrlr(self, user):
if self.status(user) == status_allowed:
return ("<a href=\"%s\">Sign Out</a>)" %
(users.create_login_url("/")))
else:
return ("<a href=\"%s\">Sign In or Get an Account</a>)" %
(users.create_logout_url("/")))
def status(self, user):
match = sub_user.gql(qu_by_user_id, user.user_id)
return match.string_status
def group(self, user):
match = sub_user.gql(qu_by_user_id, user.user_id)
grp = group_names.gql(qu_by_user_id, match.groupID)
return grp
def okstatus(self, user):
match = self.status(user)
if match == status_allowed:
return True
My understanding is that the argument "self" inside the method's calling arguments describes it as a child to the class. I've tried everything I can think of and can't find any related info online. Can someone please tell me what I'm doing wrong?
Thanks
© Stack Overflow or respective owner