as generated from: pcreate -t websauna_app hotcooler https://websauna.org/docs/tutorials/gettingstarted/tutorial_03.html
57 lines
2.1 KiB
Python
57 lines
2.1 KiB
Python
"""App entry point and configuration."""
|
|
|
|
import websauna.system
|
|
|
|
|
|
class Initializer(websauna.system.Initializer):
|
|
"""An initialization configuration used for starting hotcooler.
|
|
|
|
Override parent class methods to customize application behavior.
|
|
"""
|
|
|
|
def configure_static(self):
|
|
"""Configure static asset serving and cache busting."""
|
|
super(Initializer, self).configure_static()
|
|
|
|
self.config.registry.static_asset_policy.add_static_view('hotcooler-static', 'hotcooler:static')
|
|
|
|
def configure_templates(self):
|
|
"""Include our package templates folder in Jinja 2 configuration."""
|
|
super(Initializer, self).configure_templates()
|
|
|
|
self.config.add_jinja2_search_path('hotcooler:templates', name='.html', prepend=True) # HTML templates for pages
|
|
self.config.add_jinja2_search_path('hotcooler:templates', name='.txt', prepend=True) # Plain text email templates (if any)
|
|
self.config.add_jinja2_search_path('hotcooler:templates', name='.xml', prepend=True) # Sitemap and misc XML files (if any)
|
|
|
|
def configure_views(self):
|
|
"""Configure views for your application.
|
|
|
|
Let the config scanner to pick ``@simple_route`` definitions from scanned modules. Alternative you can call ``config.add_route()`` and ``config.add_view()`` here.
|
|
"""
|
|
# We override this method, so that we route home to our home screen, not Websauna default one
|
|
from . import views
|
|
self.config.scan(views)
|
|
|
|
def configure_models(self):
|
|
"""Register the models of this application."""
|
|
from . import models
|
|
self.config.scan(models)
|
|
|
|
def configure_model_admins(self):
|
|
"""Register the models of this application."""
|
|
|
|
# Call parent which registers user and group admins
|
|
super(Initializer, self).configure_model_admins()
|
|
|
|
# Scan our admins
|
|
from . import admins
|
|
self.config.scan(admins)
|
|
|
|
def run(self):
|
|
super(Initializer, self).run()
|
|
|
|
|
|
def main(global_config, **settings):
|
|
init = Initializer(global_config)
|
|
init.run()
|
|
return init.make_wsgi_app()
|