Google App Engine 中的多种形式和持久性
我通过类似 Django 的经过验证的表单收集输入数据,然后在验证时加载新表单,然后进行验证,然后我希望发送到数据存储。我想在第一个表单上执行临时存储,以防用户没有在第二个表单上输入完整的详细信息,我认为添加到数据存储没有太多意义。那么我应该如何在表单之间保留数据呢?每个表单都有自己的处理程序和帖子部分。
最好的方法是什么?
I'm gathering input data via a Django like validated form and then upon validating loading new form from and then validating and then I wish to send to the data store. I'd like to perform temporary storage on the first form, in case the user does not enter the full details on form two I don't see much point of adding to the datastore. So how should I persist the data between forms? Each form has its own handler and post section.
What is the best way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在表单之间保存数据的自然位置是在用户的会话中;多表单向导中的每个字段都将存储在会话中,直到最后一个表单,在确认后,数据最终应保留在 DataStore 中。
由于 Google App Engine 不在 python 环境中提供会话,我建议您为此目的安装一个简洁的库: gae 会话。
Gae-sessions 并不神奇,但它使用 Cookie+memcache+数据存储区,用于会话管理;因此,如果您不喜欢安装第三方库,您可以使用自己的会话库。
The natural place to persist data between forms is in the user's session; every fields in your multi-form wizard would be stored in session until the last form where, after the confirmation, the data should be finally persisted in the DataStore.
Since Google App Engine does not provide session in the python environment, I would suggest you to install a neat library for this purpose: gae-sessions.
Gae-sessions is not magic but it uses cookies+memcache+datastore for session management; so, if you don't like to install a third-party library, you have the ingredients to cook your own session library.
我可以描述这些选项,但 Nick Johnson 的这篇博文完美地描述了它:
App Engine 上的存储选项
I could describe the options, but this blogpost by Nick Johnson describes it perfectly:
Storage options on App Engine