Changeset 5140
- Timestamp:
- 08/12/08 00:50:14 (5 months ago)
- Files:
-
- trunk/tg/wsgiapp.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tg/wsgiapp.py
r5133 r5140 1 1 from pylons.wsgiapp import PylonsApp 2 from pylons.util import class_name_from_module_name 3 import sys 2 4 3 5 class TGApp(PylonsApp): 4 6 5 7 def find_controller(self, controller): 6 8 """Locates a controller by attempting to import it then grab 7 9 the SomeController instance from the imported module. 8 10 9 11 Override this to change how the controller object is found once 10 12 the URL has been resolved. 11 13 12 14 """ 13 15 # Check to see if we've cached the class instance for this name 14 16 if controller in self.controller_classes: 15 17 return self.controller_classes[controller] 16 17 # Pull the controllers class name, import controller 18 full_module_name = self.config.paths.controller \ 19 + controller.replace('/', '.') 20 18 19 root_module_path = self.config['paths']['root'] 20 controller_path = self.config['paths']['controllers'] 21 22 #remove the part of the path we expect to be the root part (plus one '/') 23 assert controller_path.startswith(root_module_path) 24 controller_path = controller_path[len(root_module_path)+1:] 25 26 #attach the package 27 pylons_package = self.config['pylons.package'] 28 full_module_name = pylons_package+'.'+controller_path.replace('/', '.')+'.'+controller.replace('/', '.') 29 30 print full_module_name 31 21 32 # Hide the traceback here if the import fails (bad syntax and such) 22 33 __traceback_hide__ = 'before_and_this' 23 34 24 35 __import__(full_module_name) 25 36 module_name = controller.split('/')[-1]