Some Pyramid + AJAX (Jquery) questions
In my Pyramid package directory, if I create a file calle开发者_开发知识库d
somefunction.py
and I want to call this function using $.post, what URL would I specify to call this function?If I have a view function called
aview
created inviews.py
, can I call this function by simply referring the $.post url as/aview/
.
(script files reside in the static folder)
In both cases you have to write the proper routing configuration that maps the view (that has to contain the function you want to call) to a given url. You even have a xhr parameter to further customize the request [1]. I should clarify btw that I'm more a dispatcher than a traversal guy so my answer applies to that style of configuration
[1] http://docs.pylonsproject.org/projects/pyramid/1.0/api/config.html#pyramid.config.Configurator.add_route
精彩评论