Skip to content

Instantly share code, notes, and snippets.

@mcdonc
Created January 2, 2011 21:42
Show Gist options
  • Save mcdonc/762847 to your computer and use it in GitHub Desktop.
Save mcdonc/762847 to your computer and use it in GitHub Desktop.
# myapp/subscribers.py
from myapp import helpers as h
from pyramid.events import subscriber
from pyramid.events import BeforeRender
def add_globals(event):
event['h'] = h
# myapp/__init__.py
from pyramid.config import Configurator
from pyramid.events import BeforeRender
from myapp.subscribers import add_globals
def main(global_settings, **settings):
config = Configurator()
# other config here
config.add_subscriber(add_globals, BeforeRender)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment