Changeset 5634

Show
Ignore:
Timestamp:
10/28/08 21:50:05 (2 months ago)
Author:
mramm
Message:

A few simple changes.

* Skip rendering if the controller returned a string.
* Don't update the template namespace unless the controller returned a dict
* never, ever look for helpers in a stacked object proxy.
* update to some test infrastructure code that's not yet used.

Files:

Legend:

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

    r5598 r5634  
    206206        expose decorator. 
    207207        """ 
    208  
     208             
    209209        content_type, engine_name, template_name, exclude_names = \ 
    210210            controller.decoration.lookup_template_engine(pylons.request) 
     
    212212        if content_type != CUSTOM_CONTENT_TYPE: 
    213213            pylons.response.headers['Content-Type'] = content_type 
     214         
     215        #skip all the complicated stuff if we're just passing a string along.  
     216        if isinstance(response, basestring): 
     217            return response 
     218         
    214219        # Save these objeccts as locals from the SOP to avoid expensive lookups 
    215220        req = pylons.request._current_obj() 
     
    246251        # has marked to be excluded. 
    247252        namespace = dict(tmpl_context=tmpl_context) 
    248         namespace.update(response) 
     253        if isinstance(response, dict): 
     254            namespace.update(response) 
    249255        if not engine_name in ['json']: 
    250256            namespace.update(get_tg_vars()) 
  • trunk/tg/render.py

    r5362 r5634  
    11from pylons import (app_globals, config, session, tmpl_context, request,  
    22                    response, templating) 
    3 from pylons import h as pylons_helpers 
    43import tg 
    54from tg.configuration import Bunch 
     
    121120        ) 
    122121         
    123     helpers = config.get('pylons.h') or pylons_helpers._current_obj(
     122    helpers = config.get('pylons.h') or config.get('pylons.helpers'
    124123     
    125124    root_vars = Bunch( 
  • trunk/tg/tests/test_stack/rendering/controllers/root.py

    r5586 r5634  
    55 
    66class RootController(TGController): 
    7     @expose(
     7    @expose('index.html'
    88    def index(self): 
    9         return "my foo" 
     9        return {} 
    1010 
    1111    @expose() 
  • trunk/tg/tests/test_stack/test_config.py

    r5585 r5634  
    1818 
    1919def test_basic_stack(): 
    20     """Ensure that the tg stack returns a string""" 
    2120    app = setup_noDB() 
    2221    resp = app.get('/')