Changeset 5140

Show
Ignore:
Timestamp:
08/12/08 00:50:14 (5 months ago)
Author:
percious
Message:

fixed tgapp to work with rumapp. Some interesting manipulations for the import were required, code review is recommended, but all of the tests pass.
enjoy.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tg/wsgiapp.py

    r5133 r5140  
    11from pylons.wsgiapp import PylonsApp 
     2from pylons.util import class_name_from_module_name 
     3import sys 
    24 
    35class TGApp(PylonsApp): 
    4      
     6 
    57    def find_controller(self, controller): 
    68        """Locates a controller by attempting to import it then grab 
    79        the SomeController instance from the imported module. 
    8          
     10 
    911        Override this to change how the controller object is found once 
    1012        the URL has been resolved. 
    11          
     13 
    1214        """ 
    1315        # Check to see if we've cached the class instance for this name 
    1416        if controller in self.controller_classes: 
    1517            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 
    2132        # Hide the traceback here if the import fails (bad syntax and such) 
    2233        __traceback_hide__ = 'before_and_this' 
    23          
     34 
    2435        __import__(full_module_name) 
    2536        module_name = controller.split('/')[-1]