diff --git a/cookiecutters/scaffold/cookiecutter.json b/cookiecutters/scaffold/cookiecutter.json index 7200fd03..493c6f7c 100644 --- a/cookiecutters/scaffold/cookiecutter.json +++ b/cookiecutters/scaffold/cookiecutter.json @@ -1,5 +1,5 @@ { "root_folder": "atramhasis_scaffold", "python_package": "atramhasis_scaffold", - "package_logger": "scaffold_logger" + "package_logger": "atramhasis_scaffold_logger" } diff --git a/cookiecutters/scaffold/{{cookiecutter.root_folder}}/development.ini b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/development.ini index 7ccde76f..f83b3c70 100644 --- a/cookiecutters/scaffold/{{cookiecutter.root_folder}}/development.ini +++ b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/development.ini @@ -1,7 +1,7 @@ [app:main] use = egg:{{ cookiecutter.python_package }} -sqlalchemy.url = sqlite:///%(here)s/atra.db +sqlalchemy.url = sqlite:///%(here)s/{{cookiecutter.python_package}}.sqlite [server:main] diff --git a/cookiecutters/scaffold/{{cookiecutter.root_folder}}/pyproject.toml b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/pyproject.toml index 06c8c52c..b464bb93 100644 --- a/cookiecutters/scaffold/{{cookiecutter.root_folder}}/pyproject.toml +++ b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/pyproject.toml @@ -14,7 +14,8 @@ dependencies = [ [project.optional-dependencies] dev = [ - "waitress" + "waitress", + "pyramid_debugtoolbar", ] [project.entry-points."paste.app_factory"] diff --git a/cookiecutters/scaffold/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/__init__.py b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/__init__.py index 207bc394..ff4488dd 100644 --- a/cookiecutters/scaffold/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/__init__.py +++ b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/__init__.py @@ -1,11 +1,35 @@ +import os + from pyramid.config import Configurator +from pyramid.session import SignedCookieSessionFactory +from sqlalchemy import engine_from_config + +from atramhasis.data.models import Base def main(global_config, **settings): - """ This function returns a Pyramid WSGI application.""" + """This function returns a Pyramid WSGI application.""" + + # Set up sqlalchemy + engine = engine_from_config(settings, "sqlalchemy.") + Base.metadata.bind = engine + + # set up dump location + dump_location = settings["atramhasis.dump_location"] + if not os.path.exists(dump_location): + os.makedirs(dump_location) + with Configurator(settings=settings) as config: - config.include('atramhasis') + # set default session factory + atramhasis_session_factory = SignedCookieSessionFactory( + settings["atramhasis.session_factory.secret"] + ) + config.set_session_factory(atramhasis_session_factory) + + # Set up atramhasis + config.include("atramhasis") # Set up atramhasis db - config.include('atramhasis:data.db') + config.include("atramhasis:data.db") + config.scan() return config.make_wsgi_app()