Chapter 6.4.2. Create New Classes to Encapsulate Complex Relational Logic

Feel free to create your own classes when you need to go beyond what SQLObject gives you for free.

Another general rule: Don’t have your controller check for some model state and then, depending on what you find, do any of a variety of things. When you design your code so that you can just call a method in your model, which checks whatever state needs checking and updates itself, you’re much better off.

It’s important that your model objects act like objects rather than just state-containing blobs.

If your model objects have methods that encapsulate the whole state+logic that is associated with your model, your controllers will be free to do what they are designed ...

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.