Chapter 6.4.1. Keep All Model Logic in Model Methods

The first critical thing to remember is that even though you are using a SQLObject to wrap a database that just stores your data, your model objects are not just data-containing blobs. They are full-fledged objects with methods as well as attributes. So, in addition to storing your data, they can contain program logic. Perhaps this goes without saying, but somehow people don’t seem to be used to treating their object relational mapper (ORM) classes like regular classes.

The critical thing to remember about model-viewer-controller (MVC) is that all the data, and all the rules and logic about how the data can be manipulated, ought to live in the model. The controller’s job is just to tell ...

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.