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