diff --git a/ordr/templates/404.jinja2 b/ordr/templates/errors/404.jinja2 similarity index 84% rename from ordr/templates/404.jinja2 rename to ordr/templates/errors/404.jinja2 index 1917f83..6210ec1 100644 --- a/ordr/templates/404.jinja2 +++ b/ordr/templates/errors/404.jinja2 @@ -1,4 +1,4 @@ -{% extends "layout.jinja2" %} +{% extends "ordr:templates/layout.jinja2" %} {% block content %}
diff --git a/ordr/templates/mytemplate.jinja2 b/ordr/templates/pages/welcome.jinja2 similarity index 88% rename from ordr/templates/mytemplate.jinja2 rename to ordr/templates/pages/welcome.jinja2 index 45b7d0d..4103636 100644 --- a/ordr/templates/mytemplate.jinja2 +++ b/ordr/templates/pages/welcome.jinja2 @@ -1,4 +1,4 @@ -{% extends "layout.jinja2" %} +{% extends "ordr:templates/layout.jinja2" %} {% block content %}
diff --git a/ordr/views/default.py b/ordr/views/default.py deleted file mode 100644 index 60e2c0c..0000000 --- a/ordr/views/default.py +++ /dev/null @@ -1,33 +0,0 @@ -from pyramid.response import Response -from pyramid.view import view_config - -from sqlalchemy.exc import DBAPIError - -from ..models import MyModel - - -@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() - except DBAPIError: - return Response(db_err_msg, content_type='text/plain', status=500) - return {'one': one, 'project': 'Ordr'} - - -db_err_msg = """\ -Pyramid is having a problem using your SQL database. The problem -might be caused by one of the following things: - -1. You may need to run the "initialize_ordr_db" script - to initialize your database tables. Check your virtual - environment's "bin" directory for this script and try to run it. - -2. Your database server may not be running. Check that the - database server referred to by the "sqlalchemy.url" setting in - your "development.ini" file is running. - -After you fix the problem, please restart the Pyramid application to -try it again. -""" diff --git a/ordr/views/errors.py b/ordr/views/errors.py new file mode 100644 index 0000000..8c6ae2e --- /dev/null +++ b/ordr/views/errors.py @@ -0,0 +1,7 @@ +from pyramid.view import notfound_view_config + + +@notfound_view_config(renderer='ordr:templates/errors/404.jinja2') +def notfound_view(context, request): + request.response.status = 404 + return {} diff --git a/ordr/views/notfound.py b/ordr/views/notfound.py deleted file mode 100644 index 69d6e28..0000000 --- a/ordr/views/notfound.py +++ /dev/null @@ -1,7 +0,0 @@ -from pyramid.view import notfound_view_config - - -@notfound_view_config(renderer='../templates/404.jinja2') -def notfound_view(request): - request.response.status = 404 - return {} diff --git a/ordr/views/public.py b/ordr/views/public.py new file mode 100644 index 0000000..c43d99c --- /dev/null +++ b/ordr/views/public.py @@ -0,0 +1,14 @@ +from pyramid.response import Response +from pyramid.view import view_config + +from sqlalchemy.exc import DBAPIError + +from ..models import MyModel + + +@view_config( + context='ordr.resources.RootResource', + renderer='ordr:templates/pages/welcome.jinja2' + ) +def home(context, request): + return {}