PylonsHQ.

Layout: Fixed-width

Adding Controllers without restarting (during run-time)

Unknown macro: {metadata-list}
Name Adding Controllers without restarting (during run-time)
Space Pylons Cookbook
Section Controllers
Version 1.0
Status Draft
Reviewed False
Author(s) Ben Bangert

Introduction

Sometimes, its necessary for an application to add controllers without restarting the application. This requires telling Routes (which scans the controller directory for valid routes) to re-scan the directory.

Adding the controller

The controller may be added from the command line with the paster command (recommended as that also creates the test harness file), or any other means of creating the controller file.

Telling Routes about the new controller

For Routes to become aware of new controllers present in the controller directory, Routes needs to have an internal flag toggled indicating that it should rescan the directory.

Example

1
2
3
4
from routes import request_config

mapper = request_config().mapper
mapper._created_regs = False

On the next request, Routes will rescan the controllers directory, and routes that use the ':controller' dynamic part path will be able to match the new controller.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Powered by Pylons - Contact Administrators