def get_lang_dict(self, REQUEST=None): """ MultiLanguageManager.get_lang_dict """ #-- [ReqBuff]: Fetch buffered value from Http-Request. reqBuffId = 'MultiLanguageManager.get_lang_dict' try: return self.fetchReqBuff(reqBuffId) except: pass #-- Get value. d = {} portalMaster = self.getPortalMaster() if portalMaster is not None: lang_dict = portalMaster.get_lang_dict() for key in lang_dict: d[key] = lang_dict[key].copy() lang_ids = lang_dict[key].keys() d[key]['acquired'] = standard.concat_list( d[key].get('acquired', []), lang_ids) lang_dict = self.getConfProperty('ZMS.custom.langs.dict', {}) for key in lang_dict: if key in d: lang_ids = lang_dict[key].keys() for lang_id in lang_ids: if lang_id not in d[key].get('acquired', []): d[key][lang_id] = lang_dict[key][lang_id] else: d[key] = lang_dict[key].copy() #-- Get value fron content-objects. metaobjAttrId = 'langdict' for metaobjId in self.getMetaobjIds(): if metaobjAttrId in self.getMetaobjAttrIds(metaobjId): v = self.evalMetaobjAttr("%s.%s" % (metaobjId, metaobjAttrId)) if type(v) is not dict: from ast import literal_eval v = literal_eval(v) for key in v: d[key] = v[key] #-- [ReqBuff]: Returns value and stores it in buffer of Http-Request. self.storeReqBuff(reqBuffId, d) if REQUEST is not None: REQUEST.RESPONSE.setHeader('Cache-Control', 'public, max-age=3600') REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain; charset=utf-8') return self.str_json(d) return d
def importXml(self, xml): ids = [ self.activities[x * 2] for x in range(len(self.activities) // 2) ] for id in ids: self.delItem(id, 'activities') ids = [ self.transitions[x * 2] for x in range(len(self.transitions) // 2) ] for id in ids: self.delItem(id, 'transitions') v = standard.parseXmlString(xml) l = v.get('activities', []) for li in range(len(l) // 2): id = l[li * 2] i = l[li * 2 + 1] self.setActivity(id=None, newId=id, newName=i['name'], newIconClazz=i.get('icon_clazz', ''), newIcon=i.get('icon')) l = v.get('transitions', []) for li in range(len(l) // 2): id = l[li * 2] i = l[li * 2 + 1] newData = i.get('ob', i.get('dtml', '')) newType = i.get('type', ['', 'DTML Method'][int(len(newData) > 0)]) self.setTransition(id=None, newId=id, newName=i['name'], newType=newType, newIconClass=i.get('icon_clazz', ''), newFrom=i.get('from', []), newTo=i.get('to', []), newPerformer=i.get('performer', []), newData=newData) # Create non existant roles. roles = [] for transition in self.getTransitions(): roles = standard.concat_list(roles, transition.get('performer', [])) for newRole in roles: if newRole not in self.userdefined_roles(): _accessmanager.addRole(self, newRole)
def getActivityDetails(self, id): ids = self.getActivityIds() froms = [] tos = [] for transition in self.getTransitions(): if transition['to'] is not None and len(transition['to']) > 0 and id in transition['to']: for ac_id in transition['from']: if ac_id in ids: idx = ids.index(ac_id) if idx not in froms: froms.append(idx) if transition['from'] is not None and len(transition['from']) > 0 and id in transition['from']: for ac_id in transition['to']: if ac_id in ids: idx = ids.index(ac_id) if idx not in tos: tos.append(idx) froms.sort() tos.sort() idxs = standard.concat_list(froms, tos) idx = ids.index(id) return {'froms':froms, 'tos': tos, 'idxs': idxs, 'idx': idx}
def concat_list(self, l1, l2): warn(self, 'concat_list', 'Products.zms.standard.concat_list') return standard.concat_list(l1, l2)