def getcloud(site, feed_id=None): """ Returns the tag cloud for a site or a site's subscriber. """ cloudict = fjcache.cache_get(site.id, 'tagclouds') if not cloudict: cloudict = cloudata(site) fjcache.cache_set(site, 'tagclouds', cloudict) # A subscriber's tag cloud has been requested. if feed_id: feed_id = int(feed_id) if feed_id in cloudict: return cloudict[feed_id] return [] # The site tagcloud has been requested. return cloudict[0]
def initview(request): """ Retrieves the basic data needed by all feeds (host, feeds, etc) Returns a tuple of: 1. A valid cached response or None 2. The current site object 3. The cache key 4. The subscribers for the site (objects) 5. The feeds for the site (ids) """ site_id, cachekey = fjlib.getcurrentsite(request.META['HTTP_HOST'], \ request.META.get('REQUEST_URI', request.META.get('PATH_INFO', '/')), \ request.META['QUERY_STRING']) response = fjcache.cache_get(site_id, cachekey) if response: return response, None, cachekey, [], [] site = models.Site.objects.get(pk=site_id) sfeeds_obj = fjlib.sitefeeds(site) sfeeds_ids = [subscriber.feed.id for subscriber in sfeeds_obj] return None, site, cachekey, sfeeds_obj, sfeeds_ids