Changeset 4542

Show
Ignore:
Timestamp:
04/29/08 06:04:01 (3 months ago)
Author:
alberto
Message:

changed inject_resources's signature

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • projects/ToscaWidgets/trunk/CHANGELOG.txt

    r4518 r4542  
    440.8.6 (unrealeased) 
    55------------------- 
     6 
    67* injector_middleware now properly handles wrapped apps that use the write 
    78  func returned by start_response 
    89 
     10* Docs are finally hitting the repository! 
     11 
     12* :func:`tw.core.resource_injector.inject_resources` has changed it's 
     13  signature making ``resources`` an optional parameter and switched places 
     14  with ``html``. 
     15 
    9160.8.5 (Ap3, 25 2008) 
    1017------------------- 
     18 
    1119* PylonsHostFramework no longer adds the extra_vars_func by default which 
    1220  made available Pylons's SOPs in every widget template namespace since some 
     
    18260.8.[1,2,3,4] (Apr, 19 2008): 
    1927----------------------------- 
     28 
    2029* Fixed various import bugs introduced in 0.8 
    2130 
    22310.8 (Apr. 19 2008): 
    2332------------------- 
     33 
    2434* Changed the name of the "toscawidgets" namespace to "tw" and moved all the 
    2535  core stuff to tw.core. Now external widget eggs packages get grafted (via 
     
    29390.3 (Apr. 19 2008): 
    3040----------------- 
     41 
    3142* Removed lxml dependency for resource injection. Now using simple 
    3243  regular expressions. 
     
    34450.2 (Jan. 25 2008): 
    3546------------------- 
     47 
    3648* Configured apydia to generate API docs. 
    3749* Links now add a v=%(mtime)d parameter to the URL to help against IEs  
     
    40520.2rc2 (Nov. 19 2007): 
    4153---------------------- 
     54 
    4255* Reworded docs/index.txt 
    4356 
  • projects/ToscaWidgets/trunk/tw/core/resource_injector.py

    r4518 r4542  
    1818import re 
    1919import logging 
     20 
    2021try: 
    2122    from cStringIO import StringIO 
    2223except ImportError: 
    2324    from StringIO import StringIO 
     25 
     26from tw import framework 
    2427from tw.core.util import MultipleReplacer 
    2528 
     
    3437    """ 
    3538    def _injector(environ, start_response): 
    36         from tw import framework 
    3739        context = {'inject':False, 'fileobj':StringIO()} 
    3840        def determine_response_type(status, headers, exc_info = None): 
     
    5860            if hasattr(app_iter, 'close'): 
    5961                app_iter.close() 
    60             # Must try to retrieve resources after consuming app_iter 
    61             resources = framework.pop_resources() 
    62             html = inject_resources(resources, html, context['charset']) 
     62            # Must try to inject resources after consuming app_iter 
     63            html = inject_resources(html, encoding=context['charset']) 
    6364            # Set updated content-length 
    6465            headers = [h for h in context['headers'] 
     
    8990        return inject 
    9091 
    91     def __call__(self, resources, html, encoding=None): 
     92    def __call__(self, html, resources=None, encoding=None): 
    9293        """Injects resources, if any, into html string. 
    9394 
     
    100101        empty dict. 
    101102        """ 
     103        if resources is None: 
     104            resources = framework.pop_resources() 
    102105        if resources: 
    103106            encoding = encoding or _find_charset(html) or 'ascii'