Example #1
0
 def objs_gen(infos, depth=0, depth_lim=2):
     # print(depth)
     objs = list_generator(infos)
     if not objs:
         return objs
     if depth == depth_lim:
         return objs
     toget = []
     for each in objs:
         if each is None:
             continue
         for ev in each.cache_info.values():
             if not ObjectId.is_valid(ev[0]):
                 continue
             if ev[0] in oids:
                 continue
             toget.append(ev)
             oids.add(ObjectId(ev[0]))
     tmps = objs_gen(toget, depth + 1)  # get_obj
     for each in tmps:
         # add obj in tmps to pool
         if each is None:
             continue
         obj_pool[each._id] = each
     for each in objs:
         # add obj in obj_pool to objs
         if each is None:
             continue
         for ek, ev in each.cache_info.items():
             if not ObjectId.is_valid(ev[0]):
                 continue
             ev = ObjectId(ev[0])
             if ev in obj_pool:
                 each.set_cache(ek, obj_pool[ev])
     return objs
Example #2
0
 def objs_gen(infos, depth=0, depth_lim=2):
     #print(depth)
     objs = list_generator(infos)
     if not objs:
         return objs
     if depth == depth_lim:
         return objs
     toget = []
     for each in objs:
         if each is None:
             continue
         for ev in each.cache_info.values():
             if not ObjectId.is_valid(ev[0]):
                 continue
             if ev[0] in oids:
                 continue
             toget.append(ev)
             oids.add(ObjectId(ev[0]))
     tmps = objs_gen(toget, depth + 1)  #get_obj
     for each in tmps:
         #add obj in tmps to pool
         if each is None:
             continue
         obj_pool[each._id] = each
     for each in objs:
         #add obj in obj_pool to objs
         if each is None:
             continue
         for ek, ev in each.cache_info.items():
             if not ObjectId.is_valid(ev[0]):
                 continue
             ev = ObjectId(ev[0])
             if ev in obj_pool:
                 each.set_cache(ek, obj_pool[ev])
     return objs
Example #3
0
 def post(self):
     handler_para = GetArticleOverviewsPara(self)
     handler_json = GetArticleOverviewsJson(self)
     usr = self.current_user
     toload = list_generator(handler_para['toload'])
     toload = [each for each in toload if each]
     toload.sort()
     handler_json['article_list'] = [each.json_info_view_by(usr)
                         for each in toload]
     handler_json.by_status(0)
     handler_json.write()
     return
Example #4
0
 def post(self):
     handler_para = GetArticleOverviewsPara(self)
     handler_json = GetArticleOverviewsJson(self)
     usr = self.current_user
     toload = list_generator(handler_para['toload'])
     toload = [each for each in toload if each]
     toload.sort()
     handler_json['article_list'] = [
         each.json_info_view_by(usr) for each in toload
     ]
     handler_json.by_status(0)
     handler_json.write()
     return