I am trying to get my pyramid app to use pyramid_jinja2 and pyramid_webassets.
My main config function looks a little like this:
def main(global_config, **settings):
engine = engine_from_config(settings, 'sqlalchemy.', encoding='utf-8')
get_root = appmaker(engine)
session_factory = session_factory_from_settings(settings)
config = Configurator(settings=settings, root_factory=get_root)
config.include('pyramid_handlers')
config.include('pyramid_jinja2')
config.add_jinja2_renderer('.html')
config.add_jinja2_search_path('myapp:templates', name='.html')
config.include('pyramid_webassets')
config.add_jinja2_extension('webassets.ext.jinja2.AssetsExtension')
assets_env = config.get_webassets_env()
jinja2_env = config.get_jinja2_environment()
jinja2_env.assets_environment = assets_env
After going through the docs multiple times it seems to be configured correctly but I keep getting the error:
jinja2_env.assets_environment = assets_env
AttributeError: 'NoneType' object has no attribute 'assets_environment'
Not sure as to why jinja2_env
is remaining undefined. The only dependency should be pyramid_jinja2
which is definitely being used and set on the config object. Any insights or examples to configs with jinja2 and webassets would be much appreciated.
This answered my question - https://github.com/Pylons/pyramid_jinja2/issues/111
needed a config.commit()
in there.