Esempio n. 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]))
Esempio n. 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
Esempio n. 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]))
Esempio n. 4
0
 def multiget(cls, ids, force_db=False):
     if force_db:
         return TopList.objects.filter(id__in=ids)
     return cache.get(cls, ids)
Esempio n. 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)
Esempio n. 6
0
 def multiget(cls, ids, force_db=False):
     if force_db:
         return TopList.objects.filter(id__in=ids)
     return cache.get(cls, ids)
Esempio n. 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)
Esempio n. 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)
Esempio n. 9
0
def manage_org(request, org_id, tab='about'):
    try:
        org = cache.get(Org, org_id)
    except Exception, inst:
        raise Http404
Esempio n. 10
0
 def entity(self):
     return cache.get(type_to_class(self.entity_type), self.entity_id)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 14
0
 def get(cls, id, force_db=False):
     if force_db:
         return Message.objects.get(id=id)
     return cache.get(cls, id)
Esempio n. 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)