def __init__(self): self.def_locale = "en" self.active_locale = "en" self.pool = pool.getCachePool() self.def_dict = {} self.enable_locale = True self.pool.setLOCALEDict(self.def_locale, self.def_dict) self.act_dict = self.pool.getLOCALEDict(self.active_locale)
def updateDIVICache(self, obj): pool = ecfpool.getCachePool() cmp_pool = pool.getDIVDict(obj.CMDVCONO, obj.CMDVDVNO) if cmp_pool is None: cmp_pool = {} for key in CMPDIV.__dict__.iterkeys(): if isinstance(CMPDIV.__dict__[key], InstrumentedAttribute): cmp_pool[key] = getattr(obj, key, None) pool.setDIVDict(obj.CMDVCONO, obj.CMDVDVNO, cmp_pool)
def updateCOMPCache(self, obj): pool = ecfpool.getCachePool() cmp_pool = pool.getCOMPDict(obj.CMCPCONO) if cmp_pool is None: cmp_pool = {} for key in MSTCMP.__dict__.iterkeys(): if isinstance(MSTCMP.__dict__[key], InstrumentedAttribute): cmp_pool[key] = getattr(obj, key, None) pool.setCOMPDict(obj.CMCPCONO, cmp_pool)
def getUserInfo(self, usrname): pool = ecfpool.getCachePool() if usrname != None: usr_pool = pool.getUserDict(usrname) if usr_pool is None: obj = EFUSRS.get(usrname) if obj is not None: self.updateUserCache(obj, usr_pool) usr_pool = pool.getUserDict(usrname) if usr_pool: return (usr_pool['EFUSFSNM'], usr_pool['EFUSLSNM'], usr_pool['EFUSCONO'], usrname, usr_pool['EFUSDVNO']) return (None, None, None, None, None, None)
def getCompany(self, cono): """ Get company code, name, default currency, and default rate used """ cono = cono if cono else '' pool = ecfpool.getCachePool() cmp_cache = pool.getCOMPDict(cono) if cmp_cache is None: obj = MSTCMP.get(cono) if obj: self.updateCOMPCache(obj) return (obj.CMCPCONO, obj.CMCPCONM, obj.CMCPCUCD, obj.CMCPRTCD) else: return (None, None, None, None) return (cmp_cache['CMCPCONO'], cmp_cache['CMCPCONM'], cmp_cache['CMCPCUCD'], cmp_cache['CMCPRTCD'])
def retrieveUserInfo(self, mvcsession): pool = ecfpool.getCachePool() usr_name = mvcsession.cookies['user_name'].encode('utf8') if usr_name != None: usr_pool = pool.getUserDict(usr_name) if usr_pool is None: obj = EFUSRS.query.filter_by(EFUSUSID = usr_name) \ .first() if obj is not None: usr_pool = self.updateUserCache(obj) else: usr_pool = pool.getUserDict(usr_name) if usr_pool: return (usr_pool['EFUSFSNM'], usr_pool['EFUSLSNM'], usr_pool['EFUSCONO']) else: return (None, None, None)
def getDivision(self, cono, divi): """ Get division company code, comp. name, div. code, and div. name """ cono = cono if cono else '' divi = divi if divi else '' cmpno, cmpnm, divino, divinm = (None, None, None, None) pool = ecfpool.getCachePool() divi_cache = pool.getDIVDict(cono, divi) if divi_cache is None: obj = CMPDIV.get((cono, divi)) if obj: self.updateDIVICache(obj) cmpno, cmpnm, divino, divinm = (obj.CMDVCONO, obj.CMDVCONM, obj.CMDVDVNO, obj.CMDVDVNM) else: cmpno, cmpnm, divino, divinm = (divi_cache['CMDVCONO'], divi_cache['CMDVCONM'], divi_cache['CMDVDVNO'], divi_cache['CMDVDVNM']) cmpno, cmpnm, tmp1, tmp2 = self.getCompany(cmpno) return (cmpno, cmpnm, divino, divinm)
def retrieveUserInfoDict(self, mvcsession): pool = ecfpool.getCachePool() usrname = mvcsession.cookies['user_name'].encode('utf8') usr_pool = pool.getUserDict(usrname) if usr_pool is None: obj = EFUSRS.query.filter_by(EFUSUSID = usrname) \ .first() if obj is not None: usr_pool = self.updateUserCache(obj) ret_dict = { 'USRNAME': mvcsession.cookies['user_name'].encode('utf8'), 'USRFNAME': None, 'USRLNAME': None, 'USRCONO': None, 'USRDVNO': None } if usr_pool: ret_dict['USRFNAME'] = usr_pool['EFUSFSNM'] ret_dict['USRLNAME'] = usr_pool['EFUSLSNM'] ret_dict['USRCONO'] = usr_pool['EFUSCONO'] ret_dict['USRDVNO'] = usr_pool['EFUSDVNO'] return ret_dict
def removeDIVICache(self, obj): pool = ecfpool.getCachePool() pool.delDIVDict(obj.CMDVCONO, obj.CMDVDVNO)
def removeCOMPCache(self, obj): pool = ecfpool.getCachePool() pool.delCOMPDict(obj.CMCPCONO)
def removeUserCache(self, obj): pool = ecfpool.getCachePool() pool.delUserDict(obj.EFUSUSID)
def updateUserCache(self, obj): pool = ecfpool.getCachePool() usr_pool = {} self.setUserValues(obj, usr_pool) pool.setUserDict(obj.EFUSUSID, usr_pool) return usr_pool