示例#1
0
    def on_revision_by_id(self, request, rid):
        result = super().on_revision_by_id(request, rid)

        result.refs = refs = Record()
        refs.branch = self.build_url(request,
                                     "branches.branch_by_id",
                                     bid=result.rid.branch)

        refs.ancestors = Record()
        for number, rid in enumerate(result.ancestors):
            refs.ancestors[number] = self.build_url(request,
                                                    "revisions.revision_by_id",
                                                    rid=rid)

        refs.nodes = Record()
        for number, node_ref in enumerate(result.nodes):
            refs.nodes[number] = self.build_url(request,
                                                "nodes.by_uid",
                                                uid=NodeId(
                                                    node_ref, result.rid))

        refs.nodes_refs = Record()
        for number, (ref, rid) in enumerate(result.nodes_refs.items()):
            refs.nodes_refs[number] = self.build_url(request,
                                                     "nodes.by_uid",
                                                     uid=NodeId(
                                                         ref, result.rid))

        return result
示例#2
0
    def on_all_branches(self, request): 
        branches = list(self.runtime.get_branches())

        result = Record()
        result.branches = branches

        return result
示例#3
0
    def on_all_branches(self, request):
        branches = list(self.runtime.get_branches())

        result = Record()
        result.branches = branches

        return result
示例#4
0
    def on_intro(self, request):
        """
        This page shows current routing table with endpoints and descriptions.
        """

        result = Record()
        result.rules = rules = Record()
        for rule in self.urlmap.iter_rules():
            rules[rule.rule] = self.render_rule(request, rule)
        return result
示例#5
0
    def on_all_branch_revisions(self, request, bid):
        branch = self.runtime.get_branch(BranchId.from_string(bid))
        if branch is None:
            raise NotFound()
        revisions = list(self.runtime.get_revisions(branch.id))

        result = Record()
        result.revisions = revisions

        return result
示例#6
0
    def on_all_branch_revisions(self, request, bid):
        branch = self.runtime.get_branch(BranchId.from_string(bid))
        if branch is None:
            raise NotFound()
        revisions = list(self.runtime.get_revisions(branch.id))

        result = Record()
        result.revisions = revisions

        return result
示例#7
0
    def on_all_branch_revisions(self, request, bid):
        result = super().on_all_branch_revisions(request, bid)

        result.refs = refs = Record()
        refs.revisions = Record()
        for number, rid in enumerate(result.revisions):
            refs.revisions[number] = self.build_url(request,
                                                    "revisions.revision_by_id",
                                                    rid=rid)

        return result
示例#8
0
    def on_all_branches(self, request):
        result = super().on_all_branches(request)

        result.refs = refs = Record()
        refs.branches = Record()
        for number, bid in enumerate(result.branches):
            refs.branches[number] = self.build_url(request,
                                                   "branches.branch_by_id",
                                                   bid=bid)

        return result
示例#9
0
    def on_branch_by_id(self, request, bid):
        branch = self.runtime.get_branch(BranchId.from_string(bid))
        if branch is None:
            raise NotFound()

        result = Record()
        result.bid = branch.id
        result.revision = branch.revision
        result.wc = branch.wc.id

        return result
示例#10
0
    def on_branch_by_id(self, request, bid):
        branch = self.runtime.get_branch(BranchId.from_string(bid))
        if branch is None:
            raise NotFound()

        result = Record()  
        result.bid = branch.id
        result.revision = branch.revision
        result.wc = branch.wc.id

        return result
示例#11
0
    def on_by_uid(self, request, uid):
        uid = NodeId.from_string(uid)
        node = self.runtime.get_node(uid)
        if node is None:
            raise NotFound()

        result = Record()
        result["="] = type(node).__name__
        result.ref = node.ref
        result.data = node.content

        return result
示例#12
0
 def inspect(self, request, revision, value):
     if isinstance(value, NodeRef):
         uid = NodeId(value, revision.search(value).id)
         return self.build_url(request, "nodes.by_uid", uid=uid)
     elif isinstance(value, tuple):
         result = Record()
         for number, subvalue in enumerate(value):
             subinspect = self.inspect(request, revision, subvalue)
             if subinspect is not None:
                 result[number] = subinspect
         if result: return result
     elif isinstance(value, ReadOnlyDict):
         result = Record()
         for name, subvalue in value.items():
             subinspect = self.inspect(request, revision, subvalue)
             if subinspect is not None:
                 result[name] = subinspect
         if result: return result
示例#13
0
    def render_rule(self, request, rule):
        result = Record()
        result.endpoint=rule.endpoint

        segments = rule.endpoint.split(".")
        try:
            endpoint = reduce(getitem, segments, self)
        except KeyError:
            endpoint = None
       
        if rule.methods is not None:
            result.methods = tuple(rule.methods)
        
        description = getdoc(endpoint)
        if description is not None:
            result.description = description

        return result
示例#14
0
    def on_branch_by_id(self, request, bid):
        result = super().on_branch_by_id(request, bid)

        result.refs = refs = Record()
        refs.list = self.build_url(request, "branches.all_branches")
        refs.revisions = self.build_url(request,
                                        "branches.all_branch_revisions",
                                        bid=bid)
        refs.wc = self.build_url(request,
                                 "revisions.revision_by_id",
                                 rid=result.wc)

        return result
示例#15
0
    def on_by_uid(self, request, uid):
        result = super().on_by_uid(request, uid)

        uid = NodeId.from_string(uid)
        revision = self.runtime.get_revision(uid.revision)

        result.refs = refs = Record()
        for name, value in result.data.items():
            inspected = self.inspect(request, revision, value)
            if inspected is not None:
                refs[name] = inspected

        return result
示例#16
0
    def on_revision_by_id(self, request, rid):
        rid = RevisionId.from_string(rid)
        revision = self.runtime.get_revision(rid)
        if revision is None:
            raise NotFound()

        result = Record()
        result.rid = revision.id
        result.finished = revision.finished
        result.ancestors = revision.ancestors
        result.nodes = revision.nodes
        result.nodes_refs = revision.refs

        return result
示例#17
0
    def on_revision_by_id(self, request, rid): 
        rid = RevisionId.from_string(rid)
        revision = self.runtime.get_revision(rid)
        if revision is None:
            raise NotFound()

        result = Record()
        result.rid = revision.id
        result.finished = revision.finished
        result.ancestors = revision.ancestors
        result.nodes = revision.nodes
        result.nodes_refs = revision.refs

        return result