~divmod-dev/divmod.org/trunk

« back to all changes in this revision

Viewing changes to Nevow/examples/nestedsequence/nestedsequence.py

  • Committer: Jean-Paul Calderone
  • Date: 2014-06-29 20:33:04 UTC
  • mfrom: (2749.1.1 remove-epsilon-1325289)
  • Revision ID: exarkun@twistedmatrix.com-20140629203304-gdkmbwl1suei4m97
mergeĀ lp:~exarkun/divmod.org/remove-epsilon-1325289

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from twisted.python.components import registerAdapter
2
 
from nevow import rend, loaders, tags as t, inevow, accessors
3
 
 
4
 
class Edge(object):
5
 
    pass
6
 
 
7
 
class Vertex(object):
8
 
    def __init__(self, name):
9
 
        self.name = name
10
 
        self.edges = []
11
 
 
12
 
v1 = Vertex('v1')
13
 
v2 = Vertex('v2')
14
 
v3 = Vertex('v3')
15
 
v1.edges = [Edge(), Edge(), Edge(), Edge()]
16
 
v2.edges = [Edge(), Edge(), Edge(), Edge()]
17
 
v3.edges = [Edge(), Edge(), Edge(), Edge()]
18
 
 
19
 
class Root(rend.Page):
20
 
    addSlash = True
21
 
    docFactory = loaders.stan(
22
 
        t.html[
23
 
            t.head[t.title["Nested Sequence"]],
24
 
            t.body[
25
 
                t.ul(data=t.directive("vertexes"), render=t.directive("sequence"))[
26
 
                    t.li(pattern="item")[
27
 
                        t.span(data=t.directive("name"), render=t.directive("string")),
28
 
                        t.ul(data=t.directive('edges'), render=t.directive("sequence"))[
29
 
                            t.li(pattern="item", render=t.directive("string"))
30
 
                            ]
31
 
                        ]
32
 
                    ]
33
 
                ]
34
 
            ]
35
 
        )
36
 
    
37
 
    def data_vertexes(self, ctx, data):
38
 
        return [v1, v2, v3]
39
 
 
40
 
registerAdapter(accessors.ObjectContainer, Vertex, inevow.IContainer)