def archive_thread(self): if not time: return while True: time.sleep(int(config.get("archive.interval", 60))) archive_nodes_3 = db.getNodeIdByAttribute("archive_state", "3") archive_nodes_2 = [] date_now = format_date(now(), "yyymmddhhmmss") for manager in self.manager: # search for nodes to archive after access over period (state 2) for n in db.getNodeIdByAttribute("archive_state", "2"): try: node = tree.getNode(n) if node.get("archive_date"): date_archive = format_date(parse_date(node.get("archive_date"), "%Y-%m-%dT%H:%M:%S"), "yyymmddhhmmss") if date_now >= date_archive: archive_nodes_2.append(long(node.id)) except: pass # union to get all nodes with state 3 and 2 with over period archive_nodes = union((archive_nodes_3, archive_nodes_2)) nodes = intersection((db.getNodeIdByAttribute("archive_type", str(manager)), archive_nodes)) # run action defined in manager try: self.manager[manager].actionArchive(nodes) except: pass
def stat(self, attribute=""): stat = {} stat['name'] = str(self) stat['used'] = db.getNodeIdByAttribute("archive_type", str(self)) stat['state1'] = len(intersection([stat['used'], db.getNodeIdByAttribute("archive_state", "1")])) stat['state2'] = len(intersection([stat['used'], db.getNodeIdByAttribute("archive_state", "3")])) stat['state3'] = len(intersection([stat['used'], db.getNodeIdByAttribute("archive_state", "3")])) stat['used'] = len(stat['used']) if attribute == "": return stat elif attribute in stat.keys(): return stat[attribute]
def load_shoppingbagByKey(req): bagkey = req.params.get("bagkey", "") if bagkey == "": return 1 for user in users.loadUsersFromDB(): for c in user.getShoppingBag(): if c.getSharedKey() == bagkey: req.session["shoppingbag"] = c.getItems() return 1 candidates = db.getNodeIdByAttribute("key", bagkey) home_root = tree.getRoot("home") for cand in candidates: n = tree.getNode(cand) if not n.getContentType() == "shoppingbag": continue if isDescendantOf(n, home_root): req.session["shoppingbag"] = n.getItems() return 1 return 0