default.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # -*- coding: utf-8 -*-
  2. # TODO - G.M - 29-03-2018 - [Cleanup] Drop this file
  3. from pyramid.response import Response
  4. from pyramid.view import view_config
  5. from sqlalchemy.exc import DBAPIError
  6. from ..models import Content
  7. @view_config(route_name='home', renderer='../templates/mytemplate.jinja2')
  8. def test_config(request):
  9. try:
  10. project = request.config().WEBSITE_TITLE
  11. except Exception as e:
  12. return Response(e, content_type='text/plain', status=500)
  13. return {'project': project}
  14. # @view_config(route_name='home', renderer='../templates/mytemplate.jinja2')
  15. # def my_view(request):
  16. # try:
  17. # query = request.dbsession.query(MyModel)
  18. # one = query.filter(MyModel.name == 'one').first()
  19. # except DBAPIError:
  20. # return Response(db_err_msg, content_type='text/plain', status=500)
  21. # return {'one': one, 'project': 'tracim'}
  22. db_err_msg = """\
  23. Pyramid is having a problem using your SQL database. The problem
  24. might be caused by one of the following things:
  25. 1. You may need to run the "initialize_tracim_db" script
  26. to initialize your database tables. Check your virtual
  27. environment's "bin" directory for this script and try to run it.
  28. 2. Your database server may not be running. Check that the
  29. database server referred to by the "sqlalchemy.url" setting in
  30. your "development.ini" file is running.
  31. After you fix the problem, please restart the Pyramid application to
  32. try it again.
  33. """