Yes, perfect Anthony. Thanks a lot for forbearing with me. Anyway it is my pleasure to learn from the group.
I put the above code in my login action as below. It is working perfectly.
def login():
form = FORM(TABLE(
TR('User Name:',INPUT( _name='txtUName',_id='txtUName',requires=[IS_NOT_EMPTY(),IS_LENGTH(6,6),IS_MATCH('^e\d{5}',error_message='not valid user name.')])),
TR('Password:', INPUT (_name='txtPwd', _id='txtPwd', _type='password',requires=[IS_NOT_EMPTY(),IS_LENGTH(8,6)])),
INPUT (_type='submit',_value='Login')
)
)
msg=''
if form.process(keepvalues=True).accepted:
lcUname = form.vars.txtUName
lcPwd = form.vars.txtPwd
lnCode = 10
lcMsg = 'y'
from gluon.contrib.pysimplesoap.client import SoapClient
client = SoapClient(wsdl="
http://172.16.164.64/ws_ts2admin/ts2admin.asmx?WSDL")
rs = client.ValidateLogin(lcUname, lcPwd, lnCode, lcMsg)
rs1 = rs['ValidateLoginResult']
ret_code = rs1['Code']
ret_msg = rs1['Msg']
#print ret_msg
lcAppId = 'vb_cont'
if ret_code == 1:
rs2 = client.ValidateAppUser(lcUname,lcAppId)
rs3 = rs2['ValidateAppUserResult']
rs4 = rs3['Code']
if rs4 == 1:
rows = db.executesql("exec admin_get_user_details @lcUserName = ?",placeholders=([lcUname]),as_dict=True)
for i in rows:
session.divn = i['amcdcod']
session.sec = i['amcscod']
session.unit = i['unitid']
session.logged_in = True
session.uname = lcUname
if 'auth' in session:
session.auth = None
if not 'auth' in session:
session.auth = Storage(hmac_key=web2py_uuid(), user=True) redirect(URL('amc','new_contract'))
else:
response.flash ='Not a user of app.'
else:
response.flash = ret_msg
return dict(form=form,msg=msg)
def logout():
session.logged_in = None
session.uname = None
session.auth = None
session.divn = None
session.sec = None
session.unit = None