示例#1
0
 def get_related_orgs_for_user(self, user):
     if not hasattr(self, "_all_related_orgs") or getattr(self, "_all_related_orgs") is None:
         self.get_all_related_orgs
     pos = dict((id, idx) for idx, id in enumerate(self._all_related_orgs["ids"]))
     orgs = sorted(
         list(set(self._all_related_orgs["ids"]).difference(user.get_orgs_following_ids)), key=lambda id: pos[id]
     )
     return list(cache.get(Org, orgs[0:5]))
示例#2
0
    def process_request(self, request):
        if ACCOUNT_COOKIE in request.COOKIES and ACCOUNT_COOKIE_SALT in request.COOKIES:
            if check_cookie(request.COOKIES[ACCOUNT_COOKIE], request.COOKIES[ACCOUNT_COOKIE_SALT]):
                try:
                    request.user = cache.get(User, int(request.COOKIES[ACCOUNT_COOKIE]))
                    return None
                except:
                    pass

        request.user = AnonymousUser()
        return None
示例#3
0
 def get_related_orgs_for_user(self, user):
     if not hasattr(self, '_all_related_orgs') or getattr(
             self, '_all_related_orgs') is None:
         self.get_all_related_orgs
     pos = dict(
         (id, idx) for idx, id in enumerate(self._all_related_orgs['ids']))
     orgs = sorted(list(
         set(self._all_related_orgs['ids']).difference(
             user.get_orgs_following_ids)),
                   key=lambda id: pos[id])
     return list(cache.get(Org, orgs[0:5]))
示例#4
0
 def multiget(cls, ids, force_db=False):
     if force_db:
         return TopList.objects.filter(id__in=ids)
     return cache.get(cls, ids)
示例#5
0
 def get(cls, id, force_db=False):
     if force_db:
         top_list = TopList.objects.get(id=id)
         cache.bust(top_list)
         return top_list
     return cache.get(cls, id)
示例#6
0
 def multiget(cls, ids, force_db=False):
     if force_db:
         return TopList.objects.filter(id__in=ids)
     return cache.get(cls, ids)
示例#7
0
 def get(cls, id, force_db=False):
     if force_db:
         top_list = TopList.objects.get(id=id)
         cache.bust(top_list)
         return top_list
     return cache.get(cls, id)
示例#8
0
 def get(cls, id, force_db=False):
     if force_db:
         org = User.objects.get(id=id)
         cache.bust(org)
         return org
     return cache.get(cls, id)
示例#9
0
文件: views.py 项目: Bartelo/openjumo
def manage_org(request, org_id, tab='about'):
    try:
        org = cache.get(Org, org_id)
    except Exception, inst:
        raise Http404
示例#10
0
 def entity(self):
     return cache.get(type_to_class(self.entity_type), self.entity_id)
示例#11
0
 def get(cls, id, force_db=False):
     if force_db:
         obj = cls.objects.get(id=id)
         cache.bust(obj)
         return obj
     return cache.get(cls, id)
示例#12
0
 def get(cls, id, force_db=False):
     if force_db:
         org = User.objects.get(id=id)
         cache.bust(org)
         return org
     return cache.get(cls, id)
示例#13
0
 def get(cls, id, force_db=False):
     if force_db:
         issue = Issue.objects.get(id=id)
         cache.bust(issue)
         return issue
     return cache.get(cls, id)
示例#14
0
 def get(cls, id, force_db=False):
     if force_db:
         return Message.objects.get(id=id)
     return cache.get(cls, id)
示例#15
0
 def multiget(cls, ids, force_db=False):
     if force_db:
         # For sorting
         message_dict = dict((message.id, message) for message in Message.objects.filter(id__in=ids))
         return [message_dict[id] for id in ids]
     return cache.get(cls, ids)