0
聰明的人,我需要你的智慧。我有一個使用URL-Dispatch的應用程序。幾天前,我嘗試應用關於遍歷的新知識,這些知識來自教程。當然,它不工作:)金字塔遍歷問題
我會非常感謝,如果你可能看看這段代碼,並說我的問題在哪裏。 (爲了方便,有link on GitHub)
我只得到«404錯誤»,而我試圖從«/ points»得到迴應。而且,是的,我不僅在«Traversal»中是新手,而且在金字塔也是。正如你可以看到... ...
resorces.py:
class Resource(object):
def __init__(self, request=None, parent=None, name=None):
self.request = request
self.__parent__ = parent
self.__name__ = str(name)
class Root(Resource):
def __getitem__(self, item):
if item == 'points':
return Points(self.request, self, item)
else:
raise KeyError('Nope')
class Points(Resource):
def __getitem__(self, item):
if item:
return Point(self.request, self, item)
else:
raise KeyError('Nope')
class Point(Resource):
pass
views.py:
def points_get_all(context, request):
return context.__name__
__init__.py:
from pyramid.config import Configurator
from .resources import (Root, Points)
from .views import points_get_all
def main(global_config, **settings):
config = Configurator(settings=settings, root_factory=Root)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_view(points_get_all, context=Points, renderer='json')
config.add_static_view('/', 'gps_tracker:templates/', cache_max_age=0)
config.scan()
return config.make_wsgi_app()