def get(self, user, alias, docname, format=None): lang=None; charset=None logging.info([user, alias, docname, lang, charset, format]) if not alias: return self.not_found(self.request.uri) alias = api.find_alias(None, alias) if not docname: docname = alias.default_page elif docname.endswith('/'): docname += alias.default_leaf unid = "~%s/%s" % (alias.handle, docname) self.server._reload(alias) stat = self.server.stat(unid) if not format: format='html' if not stat: if stat.srcnfo: cache = model.BuildCache.all().ancestor(stat.srcnfo).get() if cache: cache.delete() pr = self.server.process(unid, format='rst') assert not pr.errors, map(lambda x:x.astext(), pr.errors) cached = model.BuildCache.get_by_key_name(format, stat.srcnfo) if cached: output = cached.output else: output = self.server.publish(unid, format).output srcnfo = api.find_sourceinfo(alias, unid) model.BuildCache(key_name=format, output=output, parent=srcnfo).put() return mediatype_for_extension(format), output
def get(self, doc_name, format, **params): if self.is_devhost(): alias = api.find_alias(None,'BL Dev') assert alias, "BL Dev has not been initialized. " else: alias = api.find_alias(None,'Blue Lines') assert alias, "Blue Lines has not been initialized. " if not doc_name: doc_name = alias.default_page elif doc_name.endswith('/'): doc_name += alias.default_leaf unid = "~%s/%s" % (alias.handle, doc_name) logger.info("StaticPage GET %s", unid) self.server._reload(alias) stat = self.server.stat(unid) if not format: format='html' if not stat: if stat.srcnfo: # clear cache cache = model.BuildCache.all().ancestor(stat.srcnfo).get() if cache: cache.delete() logger.info("StaticPage: %s needs (re)proc.", unid) # TODO: work in progress.. #return self.multistep(API+'/process', self.request.uri) pr = self.server.process(unid, format='rst') assert not pr.errors, map(lambda x:x.astext(), pr.errors) cached = model.BuildCache.get_by_key_name(format, stat.srcnfo) if cached: output = cached.output else: output = self.server.publish(unid, format).output srcnfo = api.find_sourceinfo(alias, unid) model.BuildCache(key_name=format, output=output, parent=srcnfo).put() return mediatype_for_extension(format), output
def getinfo(self, alias, *ids): # {{{ assert isinstance(alias, Alias), "Need Alias, not %s" % type(alias) for id in ids or self.getall(alias): yield api.find_sourceinfo(alias, id)