Chapter 7.1. Dashboard Controller

If you keep adding more and more methods to the same controllers.py file, it’s going to get out of hand pretty quickly. Luckily, it’s easy to handle this growing complexity by moving some pieces out to separate modules. WhatWhat has separate controller modules for the Dashboard, Project, People, Recent Changes, and Feed features. We won’t have time to look at each of these in depth, but we do take a look at a few of them to see what we can learn.

Remember that everything in CherryPy is built up off of the root controller. To mount classes from other modules, you just import the controller you’re keeping in a separate file and mount it within your root controller. Here’s how WhatWhat does it:

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.