我正在创建一个表单,要求用户在提交数据之前进行确认.我想要一个单独的确认页面,因为我需要显示很多有关如何处理表单数据的信息.我想知道是否有一种pythonic方式在Pyramid中的表单之间传递数据.
I am creating a form that requires user confirmation before submitting the data. I would like a seperate confirmation page because I need to display quite a bit information about how the form data will be processed. I was wondering if there was a pythonic way to pass data between forms in Pyramid.
提交表单会将用户带到确认页面.因此,用于确认的视图具有存储在request.POST中的表格数据.我想知道一旦用户在确认页面上点击提交",是否有一种干净的方法可以将所有这些数据传递到最终视图.我还想向参数字典中添加一个布尔变量(确认).
Submitting the form takes the user to the confirmation page. Thus, the view for the confirmation has the form data stored in request.POST. I was wondering if there was a clean way to pass along all of this data to the final view once the user hits 'submit' on the confirmation page. I would also like to add a boolean variable, confirmed, to the dictionary of parameters.
推荐答案这不是特定于金字塔的答案,但是解决此问题的两种常见方法是:
This is not a Pyramid-specific answer, but two common approaches to this problem are:
我更喜欢2,因为这是一种无状态方法.您还可以使用完全相同的表单处理逻辑,只需检查已确认"的POST变量是否存在,即可决定要采取和查看要显示的操作(即请确认"视图,或处理和已处理"视图.)
I like 2 much better because it's a stateless method. You can also use the exact same form processing logic, and just check for the presence of your "confirmed" POST variable to decide which action to take and view to show (i.e, either the "please confirm" view, or processing and the "processed" view.)
更多推荐
在金字塔视图之间传递表单参数
发布评论