Section 12.5. Summary


12.5. Summary

  • SQLObject provides special methods _set_,_get_,_del_,_doc_ that make it easy to create custom attributes. You can use these special methods to automatically perform some calculations before an object is created, or to have calculated values automatically created whenever you get an object.

  • SQLObject provides a special _init (single underscore) method for you to use rather than the standard __init (double underscore) method to customize the initialization of your SQLObjects. Unlike SQLObject's __init method, _init is only called when your objects are created, not when they are retrieved from the database.

  • As you've already seen, SQLObject supports object types created through composition, but you can use a special InheritableSQLObject to compose objects with inheritance, the same way you would in a standard Python program.

  • You can control database connections using the begin, commit, and rollback methods on your connection object, to make managing transactions easier.

  • TurboGears implicitly creates a transaction for you for every HTTP request, which is committed when the HTTP Response is processed. This avoids the need to write boilerplate code to wrap your controller object's data access in a transaction.

  • If you want to write your own special transaction handlers, without the need for boilerplate code, you can encapsulate your functions, using standard Python function wrapping, or by using a decorator.




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