Search This Blog

04 March 2011

patching an external lib at TurboGears startup

sometimes it is useful to monkey patch an external lib

in lib/patches.py

import logging
log = logging.getLogger(__name__)

from tw.jquery import ui
from tw.api import JSLink

# update to release 1.8.9
jquery_ui189 = JSLink(modname=__name__,
               filename='public/javascript/jquery.ui.all.js')

log.warning("Patching jquery.ui.all.js to 1.8.9")
ui.jquery_ui_all_js = jquery_ui189


now we need to inform TG of our patch

in project/config/middleware.py

import qubic.backoffice.lib.patches

that's it, at startup you should see :

Starting subprocess with file monitor
16:14:12,260 WARNI [project.lib.patches] Patching jquery.ui.all.js to 1.8.9

No comments:

Post a Comment