Changeset 3577

Show
Ignore:
Timestamp:
10/28/07 10:54:14 (1 year ago)
Author:
deets
Message:

added tg.mochikit_suppress as config-option

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0/CHANGELOG.txt

    r3563 r3577  
    11TurboGears Changelog 
    22==================== 
     3 
     41.0.4: 
     5---------------------------- 
     6 
     7*Changes* 
     8    * Introduction of tg.mochikit_suppress to prevent the inclusion of  
     9      the shipped MochiKit 1.3.1. That allows to include custom mochikit versions. 
     10 
     11*Features* 
     12    * Introduction of tg.mochikit_suppress to prevent the inclusion of  
     13      the shipped MochiKit 1.3.1. That allows to include custom mochikit versions. 
    314 
    4151.0.4b2 (October, 27, 2007): 
  • branches/1.0/turbogears/qstemplates/quickstart/+package+/config/app.cfg_tmpl

    r3287 r3577  
    2828# tg.allow_json = False 
    2929 
     30# Suppress the inclusion of the shipped MochiKit version, which is rather outdated. 
     31# Attention: setting this to True and listing 'turbogears.mochikit' in 'tg.include_widgets' 
     32# is a contradiction. This option will overrule the default-inclusion to prevent version 
     33# mismatch bugs. 
     34# tg.mochikit_suppress = True 
     35 
    3036# List of Widgets to include on every page. 
    31 # for exemple ['turbogears.mochikit'] 
     37# for example ['turbogears.mochikit'] 
    3238# tg.include_widgets = [] 
    3339 
  • branches/1.0/turbogears/tests/test_form_controllers.py

    r3459 r3577  
    9393    assert "MochiKit.js" in cherrypy.response.body[0] 
    9494 
     95def test_suppress_mochikit(): 
     96    "MochiKit inclusion can be suppressed" 
     97    root = cherrypy.root 
     98    turbogears.config.update({"global":{"tg.mochikit_suppress" : True}}) 
     99    testutil.createRequest("/usemochi") 
     100    print cherrypy.response.body[0] 
     101    # repair the fixture 
     102    turbogears.config.update({"global":{"tg.mochikit_suppress" : False}}) 
     103    assert "MochiKit.js" not in cherrypy.response.body[0] 
     104 
    95105def test_mochikit_everywhere(): 
    96106    "MochiKit can be included everywhere by setting tg.mochikit_all" 
     
    101111    print cherrypy.response.body[0] 
    102112    assert "MochiKit.js" in cherrypy.response.body[0] 
     113 
     114def test_mochikit_nowhere(): 
     115    "MochiKit can be included everywhere by setting tg.mochikit_all, but setting tg.mochikit_suppress will prevent that" 
     116    root = cherrypy.root 
     117    turbogears.config.update({"global":{"tg.mochikit_all" : True}}) 
     118    turbogears.config.update({"global":{"tg.mochikit_suppress" : True}}) 
     119    testutil.createRequest("/") 
     120    turbogears.config.update({"global":{"tg.mochikit_all" : False}}) 
     121    turbogears.config.update({"global":{"tg.mochikit_suppress" : False}}) 
     122    print cherrypy.response.body[0] 
     123    assert "MochiKit.js" not in cherrypy.response.body[0] 
    103124 
    104125def test_include_widgets(): 
  • branches/1.0/turbogears/widgets/base.py

    r3366 r3577  
    542542    retrieve_javascript = set_with_self 
    543543 
    544 mochikit = JSLink("turbogears", "js/MochiKit.js") 
    545  
     544class MochiKitLink(JSLink): 
     545    """ 
     546    This is a specialized JSLink to allow for suppression of MochiKit-inclusion 
     547    by core TG.  
     548 
     549    The rationale for this is that MK it version 1.3.1 has some issues that are 
     550    remedied by MK 1.4, but the latter is unfortunately unrleased. 
     551 
     552    To remedy this, one can include MK 1.4 by oneself (using e.g. tgMochiKit) - but 
     553    this will conflict with the contained version which is made use of in several 
     554    TG widgets. 
     555 
     556    By setting the configuration option 
     557 
     558      tg.mochikit_suppress = True 
     559 
     560    the incusion of MK via built-in widgets will be suppressed. Of course then one 
     561    has to include the proper version explicitly, or via tg.include_widgets. 
     562 
     563    If 'turbogears.mochikit' is part of tg.include_widgets, a warning is issued. 
     564    """ 
     565    def retrieve_javascript(self): 
     566        if config.get('tg.mochikit_suppress', False): 
     567            if 'turbogears.mochikit' in config.get('tg.include_widgets', []): 
     568                warnings.warn("""tg.mochikit_suppress == True, but 'turbogears.mochikit' is to be included via 'tg.mochikit_suppress'. 
     569This is a contratiction, and mochikit_suppress overrides the inclusion to prevent subtle errors due to version mixing of MochkKit.""") 
     570            return set() 
     571        return super(MochiKitLink, self).retrieve_javascript() 
     572 
     573mochikit = MochiKitLink("turbogears", "js/MochiKit.js") 
    546574 
    547575class JSI18NWidget(Widget):