Configurator Scan not picking up views
Posted
by
mxmissile
on Stack Overflow
See other posts from Stack Overflow
or by mxmissile
Published on 2014-08-21T18:26:33Z
Indexed on
2014/08/22
22:21 UTC
Read the original article
Hit count: 233
New to Py and Python. I'm trying to get pyramid Configurator scan to find my views, but I seem to be missing something, it's not picking up my "view" index
here are my files:
app.py
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
if __name__ == '__main__':
config = Configurator()
config.add_route('home', '/')
config.scan()
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 6543, app)
server.serve_forever()
and index.py
from pyramid.view import view_config
from pyramid.response import Response
@view_config(route_name='home')
def index(request):
print'Incoming request'
return Response('<body><h1>Home</h1></body>')
Its returning a 404. However, if I remove config.scan()
and add the view manually it works fine.
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from index import index
if __name__ == '__main__':
config = Configurator()
config.add_route('home', '/')
config.add_view(index, route_name='home')
© Stack Overflow or respective owner