Chapter 12.1. Customizing SQLObject Classes with sqlmeta

Sometimes the default behaviors of SQLObject get in your way, and tables aren’t named the way you want them to be. Fortunately, SQLObject gives you a simple way to control that kind of thing.

You’ve already seen how to declare a model class that includes columns and corresponds to a DB table. But you haven’t seen how to take control of this process to get what you want. SQLObject enables you to control many aspects of the way your model class behaves. This is done by setting attributes of a nested class called sqlmeta. Here is a quick example:

class Person(SQLObject):
  class sqlmeta:
    table='people'
  name = StringCol()

This code looks pretty simple, but why is the nested class necessary? ...

Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.