File: disktemplates.tac

package info (click to toggle)
nevow 0.3.0-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 940 kB
  • ctags: 2,089
  • sloc: python: 8,635; makefile: 15
file content (32 lines) | stat: -rw-r--r-- 736 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import random

from twisted.application import service
from twisted.application import internet

from nevow import appserver
from nevow import loaders
from nevow import rend


class Mine(rend.Page):

    addSlash = True
    docFactory = loaders.xmlfile('disktemplates.html')

    def render_foo(self, context, data):
        return context.onePattern(random.choice(['one', 'two', 'three']))

    def data_theList(self, context, data):
        return [random.randint(0, 5000) for x in range(random.randint(0, 10))]

    def data_empty(self, context, data):
        return []


application = service.Application("disktemplates")
internet.TCPServer(
    8080, 
    appserver.NevowSite(
        Mine()
    )
).setServiceParent(application)