Section 16.8. Summary

16.8. Summary

  • Widgets provide a way to Package HTML, CSS and JavaScript into reusable components.

  • Widgets are shared between all incoming requests, so they should be stateless.

  • Widget params can be given defaults at instantiation time, values at render time, or they can be assigned a callable which will be run automatically at render time to get the proper value.

  • TurboGears provides a form widget which handles displaying its own validation errors.

  • TurboGears form widgets integrate with FormEncode to handle validation.

  • FormWidget makes it easy to create your own Validators by subclassing FancyValidator.

  • The FormWidget is a special case of the more general CompoundWidget, which you can use to create nested widget structures of your own.

  • CSSLink and JSLink provide a simple way to make sure that your pages only download the necessary files once, even if dozens or hundreds of widgets on your page include links to the same files.

  • Widgets are customizable by overriding attributes, or by subclassing.

  • The code for the AutoComplete widget shows how easy it is to integrate Java-Script, HTML, and CSS into a single reusable component.

  • Widgets are view technology, so Ajax widgets interact with controller methods that handle user actions. The AutoComplete widget shows a simple example of how that works.

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 © 2008-2017.
If you may any questions please contact us: