我使用金字塔并遇到了一个奇怪的问题。我在视图A中执行ajax请求AR。如果请求完成,则用户被重定向到视图B.如果用户返回到A,则ajax请求AR将失败,因为金字塔没有找到请求的任何视图。
如果有人需要代码,我会将其发布; - )
Thx&问候 托拜厄斯
编辑:
init .py
的摘录# adding all routes
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('main_page', '/')
config.add_route('main_contact', '/contact')
config.add_route('main_discussion_start', '/discussion/start')
config.add_route('main_discussion_issue', '/discussion/start/issue={issue}')
config.add_route('main_discussion', '/discussion/{parameters}/{service}/go')
config.add_route('main_settings', '/settings')
config.add_route('main_news', '/news')
config.add_route('main_imprint', '/imprint')
config.add_route('404', '/404')
# ajax for navigation logic, administraion, settigs and editing/viewing log
config.add_route('ajax_get_start_statements', '/discussion/{url:.*}ajax_get_start_statements')
config.add_route('ajax_get_premisses_for_statement', '/discussion/{url:.*}ajax_get_premisses_for_statement')
config.add_route('ajax_reply_for_premissegroup', '/discussion/{url:.*}ajax_reply_for_premissegroup')
config.add_route('ajax_user_login', '{url:.*}ajax_user_login')
config.add_route('ajax_user_logout', '{url:.*}ajax_user_logout')
config.add_route('ajax_set_new_start_statement', '/discussion/{url:.*}ajax_set_new_start_statement{params:.*}')
config.add_route('ajax_set_new_start_premisse', '/discussion/{url:.*}ajax_set_new_start_premisse{params:.*}')
config.add_route('ajax_set_new_premisses_for_X', '/discussion/{url:.*}ajax_set_new_premisses_for_X{params:.*}')
config.add_route('ajax_set_correcture_of_statement', '/discussion/{url:.*}ajax_set_correcture_of_statement{params:.*}')
config.add_route('ajax_user_registration', '{url:.*}ajax_user_registration')
config.add_route('ajax_user_password_request', '{url:.*}ajax_user_password_request')
config.add_route('ajax_fuzzy_search', '{url:.*}ajax_fuzzy_search')
config.add_route('ajax_get_issue_list', '{url:.*}ajax_get_issue_list')
config.add_route('ajax_switch_language', '{url:.*}ajax_switch_language{params:.*}')
在view.py
中找不到视图# 404 page
@notfound_view_config(renderer='templates/404.pt')
def notfound(self):
"""
View configuration for the 404 page.
:return: dictionary with title and project name as well as a value, weather the user is logged in
"""
logger('- - - - - - - - - - - -', '- - - - - - - - - - - -', '- - - - - - - - - - - -')
logger('notfound', 'def', 'main in ' + str(self.request.method) + '-request')
....
一个例子是ajax-call
/**
* TODO: some text
* @param statement for sending
* @param issue for sending
*/
this.sendNewStartStatement = function (statement, issue) {
var csrfToken = $('#' + hiddenCSRFTokenId).val();
$.ajax({
url: 'ajax_set_new_start_statement',
method: 'POST',
data: {
statement: statement, issue: issue
},
dataType: 'json',
async: true,
headers: {
'X-CSRF-Token': csrfToken
}
}).done(function ajaxSendStartStatementDone(data) {
new InteractionHandler().callbackIfDoneForSendNewStartStatement(data);
}).fail(function ajaxSendStartStatementFail() {
alert('fail in ajax 4');
// canceled while debuging
});
};