Hi all,
I have created a custom auth_user table.
-------------------------------------------------------------------------------------------------------
auth.settings.table_user = db.define_table('auth_user',
Field('email', length=512,default='',
requires=[IS_EMAIL(),IS_NOT_IN_DB(db,'auth_user.email')]),
Field('password', 'password',
readable=False, label='Password'),
Field('registration_key', length=512,
writable=False, readable=False,default=''),
Field('reset_password_key', length=512,
writable=False, readable=False, default=''),
Field('access_key', 'string', readable=False, writable=False))
auth.define_tables() # creates all needed
tables
t=auth.settings.table_user
t.password.requires.insert(0, CRYPT(auth.settings.hmac_key))
---------------------------------------------------------------------------------------------------------
I would like the access_key for every user to be a system generated
hashkey defaulted once when the user is created.
I tried two methods:
# Method 1
----------------------------------------------------------------------------
def access_key_gen():
if auth.user:
import hashlib
print 'called in access_key_gen'
return hashlib.md5(auth.user.email).hexdigest()
t.access_key.default=access_key_gen()
-----------------------------------------------------------------------------
# Method 2
--------------------------------------------------------------------------------------------------
if auth.user and auth.user.id and not auth.user.access_key:
print 'inside if block for access_key'
import hashlib
auth.user.access_key = hashlib.md5(auth.user.email).hexdigest()
---------------------------------------------------------------------------------------------------
Both the methods are being called correctly (verified by print
statements) but the access_key column value remains "None" - it
silently fails to update the value of auth_user.access_key for a given
user. What am I doing wrong here? I know the first method works well
for normal tables, but somehow not working for auth_user table.
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.