diff options
Diffstat (limited to 'cherrypy/tutorial/tut04_complex_site.py')
| -rw-r--r-- | cherrypy/tutorial/tut04_complex_site.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/cherrypy/tutorial/tut04_complex_site.py b/cherrypy/tutorial/tut04_complex_site.py index e0660024..3caa1775 100644 --- a/cherrypy/tutorial/tut04_complex_site.py +++ b/cherrypy/tutorial/tut04_complex_site.py @@ -5,11 +5,14 @@ This tutorial shows you how to create a site structure through multiple possibly nested request handler objects. """ +import os.path + import cherrypy class HomePage: + @cherrypy.expose def index(self): return ''' <p>Hi, this is the home page! Check out the other @@ -19,17 +22,16 @@ class HomePage: <li><a href="/joke/">A silly joke</a></li> <li><a href="/links/">Useful links</a></li> </ul>''' - index.exposed = True class JokePage: + @cherrypy.expose def index(self): return ''' <p>"In Python, how do you create a string of random characters?" -- "Read a Perl file!"</p> <p>[<a href="../">Return</a>]</p>''' - index.exposed = True class LinksPage: @@ -40,6 +42,7 @@ class LinksPage: # methods! self.extra = ExtraLinksPage() + @cherrypy.expose def index(self): # Note the way we link to the extra links page (and back). # As you can see, this object doesn't really care about its @@ -62,11 +65,11 @@ class LinksPage: <p>[<a href="../">Return</a>]</p> ''' - index.exposed = True class ExtraLinksPage: + @cherrypy.expose def index(self): # Note the relative link back to the Links page! return ''' @@ -78,7 +81,6 @@ class ExtraLinksPage: </ul> <p>[<a href="../">Return to links page</a>]</p>''' - index.exposed = True # Of course we can also mount request handler objects right here! @@ -92,7 +94,6 @@ root.links = LinksPage() # creating all contained request handler objects. -import os.path tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf') if __name__ == '__main__': @@ -100,6 +101,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(root, config=tutconf) -else: - # This branch is for the test suite; you can ignore it. - cherrypy.tree.mount(root, config=tutconf) |
