Latest Version: 0.9.6.2
  Dashboard > Pylons Cookbook > ... > Controllers > Adding Controllers without restarting (during run-time)
  Pylons Cookbook Log In | Sign Up   View a printable version of the current page.  
  Adding Controllers without restarting (during run-time)
Added by Ben Bangert, last edited by Ben Bangert on Apr 26, 2007
Labels: 
(None)

Name Space Section Version Status Reviewed Author(s)
Adding Controllers without restarting (during run-time) Pylons Cookbook Controllers 1.0 Draft False 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.

Site running on a free Atlassian Confluence Open Source Project License granted to Pylons. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.3.3 Build:#645 Feb 13, 2007) - Bug/feature request - Contact Administrators
Top