diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2017-12-17 12:34:32 -0500 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2017-12-17 12:38:41 -0500 |
| commit | 661dc06ffa9a872824d628975657b21325654f2e (patch) | |
| tree | 36027d71593578354faf50c5a227cf637388a4ff /cherrypy/tutorial/tut05_derived_objects.py | |
| parent | 49bc467811b74e100a6f5e007409e9d9baaa5f6a (diff) | |
| parent | 0e4542295a33fd776f2ca5f1bb151eb8ddf919a0 (diff) | |
| download | cherrypy-git-archive/1285-always-bytes.tar.gz | |
Merge branch 'master' into bb-pr-85archive/1285-always-bytes
Diffstat (limited to 'cherrypy/tutorial/tut05_derived_objects.py')
| -rw-r--r-- | cherrypy/tutorial/tut05_derived_objects.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/cherrypy/tutorial/tut05_derived_objects.py b/cherrypy/tutorial/tut05_derived_objects.py index 9f4f2c32..f626e03f 100644 --- a/cherrypy/tutorial/tut05_derived_objects.py +++ b/cherrypy/tutorial/tut05_derived_objects.py @@ -7,6 +7,8 @@ want to create a central base class used for all your pages, which takes care of things like printing a common page header and footer. """ +import os.path + import cherrypy @@ -45,6 +47,7 @@ class HomePage(Page): # create a subpage self.another = AnotherPage() + @cherrypy.expose def index(self): # Note that we call the header and footer methods inherited # from the Page class! @@ -54,22 +57,20 @@ class HomePage(Page): <a href="./another/">another page</a>, too! </p> ''' + self.footer() - index.exposed = True class AnotherPage(Page): title = 'Another Page' + @cherrypy.expose def index(self): return self.header() + ''' <p> And this is the amazing second page! </p> ''' + self.footer() - index.exposed = True -import os.path tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf') if __name__ == '__main__': @@ -77,6 +78,3 @@ if __name__ == '__main__': # to objects, so we need to mount a request handler root. A request # to '/' will be mapped to HelloWorld().index(). cherrypy.quickstart(HomePage(), config=tutconf) -else: - # This branch is for the test suite; you can ignore it. - cherrypy.tree.mount(HomePage(), config=tutconf) |
