~exarkun/divmod.org/remove-nevow

« back to all changes in this revision

Viewing changes to Nevow/examples/simple/simplehtml.py

  • Committer: Jean-Paul Calderone
  • Date: 2014-06-08 12:14:27 UTC
  • Revision ID: exarkun@twistedmatrix.com-20140608121427-pe4b355va5guyy03
Remove the obvious stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from twisted.python import util
2
 
 
3
 
from nevow import inevow
4
 
from nevow import loaders
5
 
from nevow import rend
6
 
from nevow import tags
7
 
 
8
 
class Simple(rend.Page):    
9
 
 
10
 
    addSlash = True
11
 
    docFactory = loaders.xmlfile(util.sibpath(__file__, 'simplehtml.html'))
12
 
 
13
 
    def render_theTitle(self, context, data):
14
 
        return context.tag["Welcome to Nevow world"]
15
 
    
16
 
    def render_sample(self, context, data):
17
 
        request = inevow.IRequest(context)
18
 
        session = inevow.ISession(context)
19
 
        count = getattr(session, 'count', 1)
20
 
        session.count = count + 1
21
 
        greeting = ["Welcome, person from ", request.client.host, "! You are using ", 
22
 
                        request.getHeader('user-agent'), " and have been here ", 
23
 
                        tags.span(id="count")[count], " times."]
24
 
        return context.tag[greeting]
25
 
 
26
 
    def child_reset(self, context):
27
 
        inevow.ISession(context).count = 1
28
 
        return '<html><body><span id="reset">Count reset</span></body></html>'