Skip to content

Instantly share code, notes, and snippets.

@ralphbean
Created March 30, 2012 12:20
Show Gist options
  • Select an option

  • Save ralphbean/2251138 to your computer and use it in GitHub Desktop.

Select an option

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
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