Created
March 30, 2012 12:20
-
-
Save ralphbean/2251138 to your computer and use it in GitHub Desktop.
Injecting tw2 jquery_ui and jquery.js on every page of a pyramid app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tw2.jqplugins.ui | |
| def remove_jq_factory(handler, registry): | |
| """ Insert tw2 jquery and jquery_ui on every page. | |
| In order to use this, you need to add the following to your | |
| myapp/__init__.py file: | |
| config.add_tween('myapp.tween.remove_jq_factory') | |
| """ | |
| def remove_jq_tween(request): | |
| # Add jquery_ui (and therefore jquery.js, too) to every page. | |
| tw2.jqplugins.ui.jquery_ui.inject() | |
| # Send the request on through to other tweens and to our app | |
| response = handler(request) | |
| # You could do some post processing here, if you wanted. | |
| return response | |
| return remove_jq_tween |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment