def devpiserver_on_upload(stage, project, version, link): if not link.entry.file_exists(): # on replication or import we might be at a lower than # current revision and the file might have been deleted already threadlog.debug("ignoring lost upload: %s", link) elif link.rel == "doczip": unpack_docs(stage, project, version, link.entry) index_project(stage, project)
def get_docs_info(request, stage, linkstore): if stage.ixconfig['type'] == 'mirror': return links = linkstore.get_links(rel='doczip') if not links: return name, ver = normalize_name(linkstore.project), linkstore.version doc_path = unpack_docs(stage, name, ver, links[0].entry) if doc_path.exists(): return dict( title="%s-%s" % (name, ver), url=request.route_url( "docviewroot", user=stage.user.name, index=stage.index, project=name, version=ver, relpath="index.html"))
def get_doc_info(context, request, version=None, check_content=True): relpath = request.matchdict['relpath'] if not relpath: raise HTTPFound(location="index.html") name = context.project if version is None: version = context.version if version == 'latest': versions = context.versions elif version == 'stable': versions = context.stable_versions else: versions = [version] doc_path = None for doc_version in versions: try: linkstore = context.stage.get_linkstore_perstage(name, doc_version) except context.stage.MissesRegistration: continue links = linkstore.get_links(rel='doczip') if not links: continue doc_path = unpack_docs(context.stage, name, doc_version, links[0].entry) if doc_path.check(): break if doc_path is None or not doc_path.check(): if version == 'stable': raise HTTPNotFound("No stable documentation available.") raise HTTPNotFound("No documentation available.") doc_path = doc_path.join(relpath) if check_content and not doc_path.check(): raise HTTPNotFound("File %s not found in documentation." % relpath) return dict(doc_path=doc_path, relpath=relpath, doc_version=doc_version, version_mismatch=doc_version != navigation_version(context))