def index(self, **kwargs): # print kwargs username = kwargs['AccountAlias'] password = kwargs['Password'] lang = kwargs['Language'] _.session['LANG'] = lang # save perfer language first import ml_w_login as wlogin login = wlogin.get(username = username, password = password) libs.tools.v(login) if login[0]: import ml_w_account as wa _.session['headers'] = _.request.headers _.session['username'] = username _.session['password'] = password libs.tools.v(username) dat = wa.get(user = username) libs.tools.v(dat) dat = wa.get(user = username)[1]['user'] for v in dat: if username == v["name"]: for kk, vv in v.items(): _.session[kk] = vv libs.tools.v(_.session.items()) raise _.HTTPRedirect('/main/') # tpl = env.get_template('default.html') # return tpl.render(userinfo=_.session) # import ml_w_login # res = ml_w_login.get(username=username, password=password) # print res # if not res[0]: # raise _.HTTPRedirect('/') # else: # raise _.HTTPRedirect('/main') else: raise _.HTTPRedirect('/')
def test_account_g01(self): """ account_g01 """ if "json" == ml_system.CFG_TYPE: shutil.copyfile(os.path.join("unittest", "account-g01.json"), os.path.join("running", "account.txt")) if "jcfg" == ml_system.CFG_TYPE: shutil.copyfile(os.path.join("unittest", "account-g01.jcfg"), os.path.join("running", "account.txt")) if "pickle" == ml_system.CFG_TYPE: return self.maxDiff = None e = ml_w_account.get(None, threading.RLock()) self.assertEqual(e, (True, { "user": [ { "name": "admin", "group": "admin", "password": "******" }, { "name": "monitor", "group": "monitor", "password": "******" } ] }))