Chapter 17. CherryPy and TurboGears Decorators


In This Chapter

  • 17.1 CherryPy URL Parsing 336

  • 17.2 CherryPy and the HTTP Request/Response Cycle 337

  • 17.3 CherryPy Filters 340

  • 17.4 CherryPy and TurboGears Configuration 343

  • 17.5 Decorators 345

  • 17.6 Error and Exception Handling 348

  • 17.7 RESTful Resources in TurboGears 350

  • 17.8 Summary 353

In this chapter, we cover the details of CherryPy and TurboGears controllers. As you have already seen, CherryPy converts URLs into calls to controller objects. In Chapter 8, "RSS, Cookies, and Dynamic Views in WhatWhat Status," you saw a foreshadowing of how CherryPy handles HTTP requests and responses, when we looked at cherrypy.request.simple_cookie. In this chapter, we take a deeper look into the details of how a user request is handled.

After we cover the basics of CherryPy, we turn to the TurboGears controller decorators. The @expose and @validate decorators make it easy to be flexible in the output that your controller gives. You can send out straight HTML, call a template to be rendered, create JSON to return to an Ajax call, or set up an XML interface to expose a web service.

Finally, we delve into REST and provide you with a simple recipe you can use with TurboGears to create RESTful interfaces for your model objects.




Rapid Web Applications with TurboGears(c) Using Python to Create Ajax-Powered Sites
Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites
ISBN: 0132433885
EAN: 2147483647
Year: 2006
Pages: 202

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net