Ejemplo n.º 1
0
	def get(self, key):
		onRequest(self)
		if key:
			cacheKey = key
			logging.debug("getting topic from cache: %s" % key)
			topic = cachetree.get(cacheKey)
			if not topic:
				logging.debug("no topic found in cache")
				topic = Topic.get(key)
				if topic: cachetree.set(key, topic)
			if topic:
				cacheKey = "%s-page-TopicView"\
					% topic.key()
				cachedPage = cachetree.get_fresh_cache(
					cacheKey,
					["%s" % topic.parent().key(),
						"%s-replies" % topic.key()])
				if not cachedPage:
					self.Model.update({
						"topic" : topic,
						"renderedReplies" : topic.render_replies_list(),
						"renderedReplyForm" : topic.render_reply_form()
					})
					self.TemplateBaseFolder = os.path.dirname(__file__)
					cachedPage = self.getRender('views/talk-TopicView.html')
					cachetree.set(cacheKey, cachedPage)
				self.response.out.write(cachedPage)
			else: self.error(404)
		else: self.error(500)
Ejemplo n.º 2
0
	def topics(self, maxResults=999, offset=0):
		key = "topicable-%s::topics-%s-%s" % (self.key(), maxResults, offset)
		topics = cachetree.get(key)
		if not topics:
			topics = Topic.all().ancestor(self).order("-Sent")\
				.fetch(limit=maxResults, offset=offset)
			cachetree.set(key, topics)
		return topics
Ejemplo n.º 3
0
	def render(self):
		cacheKey = "topic-%s" % self.key()
		renderedTopic = cachetree.get(cacheKey)
		if not renderedTopic:
			templateSource = "%s/views/talk-part-topic.html" % os.path.dirname(__file__)
			data = {"topic": self}
			renderedTopic = template.render(templateSource, data)
			cachetree.set(cacheKey, renderedTopic)
		return renderedTopic