Skip to content

Instantly share code, notes, and snippets.

@alexanderjulo
Created August 25, 2012 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexanderjulo/3470740 to your computer and use it in GitHub Desktop.
Save alexanderjulo/3470740 to your computer and use it in GitHub Desktop.
def hosturl(url):
host = www.config['HOST']
if host.endswith('/'):
host = host[0:-1]
if url.startswith('/'):
url = url[1:]
return '/'.join([host, url])
class with_app_context(object):
def __init__(self, f, app=None):
self.f = f
if app:
self.app = app
else:
self.app = www
self.__name__ = f.__name__ + '_with_app_context'
def __call__(self, *args):
with self.app.app_context():
return self.f(*args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment