diff --git a/.gitignore b/.gitignore index bfd1ac4..7471979 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# database +ordr.sqlite + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -35,6 +38,7 @@ pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports +.pytest_cache htmlcov/ .tox/ .coverage diff --git a/development.ini b/development.ini index 98cdf4f..46e3730 100644 --- a/development.ini +++ b/development.ini @@ -13,6 +13,7 @@ pyramid.debug_routematch = false pyramid.default_locale_name = en pyramid.includes = pyramid_debugtoolbar + pyramid_listing sqlalchemy.url = sqlite:///%(here)s/ordr.sqlite diff --git a/ordr/__init__.py b/ordr/__init__.py index 4dab448..14a6c1e 100644 --- a/ordr/__init__.py +++ b/ordr/__init__.py @@ -1,12 +1,18 @@ from pyramid.config import Configurator +def root_factory(request): + ''' dummy root factory ''' + return dict() + + def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ config = Configurator(settings=settings) config.include('pyramid_jinja2') config.include('.models') - config.include('.routes') + config.add_static_view('static', 'static', cache_max_age=3600) + config.set_root_factory(root_factory) config.scan() return config.make_wsgi_app() diff --git a/ordr/routes.py b/ordr/routes.py deleted file mode 100644 index 25504ad..0000000 --- a/ordr/routes.py +++ /dev/null @@ -1,3 +0,0 @@ -def includeme(config): - config.add_static_view('static', 'static', cache_max_age=3600) - config.add_route('home', '/') diff --git a/ordr/tests.py b/ordr/tests.py index 8e8c4b0..a568769 100644 --- a/ordr/tests.py +++ b/ordr/tests.py @@ -52,7 +52,7 @@ class TestMyViewSuccessCondition(BaseTest): def test_passing_view(self): from .views.default import my_view - info = my_view(dummy_request(self.session)) + info = my_view(None, dummy_request(self.session)) self.assertEqual(info['one'].name, 'one') self.assertEqual(info['project'], 'Ordr') @@ -61,5 +61,5 @@ class TestMyViewFailureCondition(BaseTest): def test_failing_view(self): from .views.default import my_view - info = my_view(dummy_request(self.session)) + info = my_view(None, dummy_request(self.session)) self.assertEqual(info.status_int, 500) diff --git a/ordr/views/default.py b/ordr/views/default.py index 4835ed3..60e2c0c 100644 --- a/ordr/views/default.py +++ b/ordr/views/default.py @@ -6,8 +6,8 @@ from sqlalchemy.exc import DBAPIError from ..models import MyModel -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') -def my_view(request): +@view_config(context=dict, renderer='../templates/mytemplate.jinja2') +def my_view(context, request): try: query = request.dbsession.query(MyModel) one = query.filter(MyModel.name == 'one').first()