Hi,
I have extended the default auth_user table in my model file db.py as
follows:
db = DAL('google:datastore')
from gluon.tools import Auth
auth = Auth(db, hmac_key=Auth.get_or_create_key())
auth.settings.extra_fields['auth_user'] = [
Field('first_name','string',required=True, notnull=True),
Field('last_name','string',default=''),
Field('fb_id','string',length=512,required=True),
Field('create_ts','datetime'),
Field('change_ts','datetime')
]
auth.define_tables()
Also below this code I have also written an insert for inserting data in
the auth_user table as:
def new_user(first_name, last_name, email, passw,fb_id):
users = db(db.auth_user.email==email).select()
if users:
return users[0].id
else:
my_crypt = CRYPT(key=auth.settings.hmac_key)
crypt_pass = my_crypt(passw)[0]
id_user= db.auth_user.insert(
first_name=first_name,
last_name=last_name,
email = email,
password = crypt_pass,
fb_id = fb_id
)
return id_user
iduser =
new_user('ABCD','EFGH','[email protected]','password','8345935345')
This insert I got from some other post in the group. The insert was
successful and auth_user table has been created.
Although no other auth table was created.
Now in my controller function I check if fb_id of a user already exists in
my auth_user table or not
def get_existing_friends():
""" This function returns a CSV text of FB_IDs of friends which already
exists """
user_fb_id = request.vars.userFBID
if db(db.auth_user.fb_id==user_fb_id).select():
return "jQuery('.foundFriends').html('This facebook user is already
registered');"
On execution nothing happens and GAE logs the following error message:
Traceback (most recent call last):
File
"/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/restricted.py",
line 204, in restricted
exec ccode in environment
File
"/home/sushant/Ekayan/src/dev/google_appengine/web2py/applications/devekayan/controllers/registration.py",
line 63, in <module>
File
"/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/globals.py",
line 172, in <lambda>
self._caller = lambda f: f()
File
"/home/sushant/Ekayan/src/dev/google_appengine/web2py/applications/devekayan/controllers/registration.py",
line 19, in get_existing_friends
if db(db.auth_user.fb_id==user_fb_id).select():
File "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/dal.py",
line 5119, in __getattr__
return self[key]
File "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/dal.py",
line 5113, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: 'auth_user'
Can somebody help me understand the above ?
Thanks,
Sushant