Beispiel #1
0
 def __init__(self, *args, **kwargs):
     #Dummy request for Cloudendpoints
     #TODO: Get current request from endpoint
     from webengine import WSGIWebEngine
     req = webapp2.Request.blank('/', base_url="http://%s" % get_app_host(include_version=False))
     req.app = WSGIWebEngine._instance
     WSGIWebEngine._instance.set_globals(app=WSGIWebEngine._instance, request=req)  # @UndefinedVariable
Beispiel #2
0
def jinja2_factory(app):
    j = jinja2.Jinja2(app)
    j.environment.filters.update({
        # Set filters.
        # ...
    })
    
    j.environment.globals.update({
        # Set global variables.
        'uri_for': webapp2.uri_for,
        'request': app.request,
        'api_host': get_app_host(include_version=False),
        'admin_views': {key:value for key, value in sorted(webengine.WSGIWebEngine.get_admin_views().iteritems(), key=lambda (k,v): v['order'], reverse=True)}

        # ...
    })
    j.environment.loader = global_jinja2.FileSystemLoader(['templates', os.path.join('webengine','templates')])
    return j