Plone:将变量从 PloneFormGen 自定义脚本适配器传递到 Mailer 适配器
我有一个带有自定义脚本适配器的 PloneFormGen 表单,在提交表单时,它会生成一个新的 uid 并创建一个以该 uid 作为其 ID 的文件夹。
from DateTime import DateTime
uid = str(DateTime().millis())
target.invokeFactory("Folder", id=uid, title=form['your-name'])
它使用表单中的输入在该文件夹中创建各种项目,包括一个名为“newpage”的文档,然后我想在电子邮件中包含该文档的链接。有没有办法将 uid 变量从脚本适配器传递到邮件适配器,以便我可以生成文件夹内新文档的链接?
例如,脚本适配器创建一个 ID 为 1317142676351 的文件夹,因此提交表单时,其中一个新页面的 URL 为 http://mysite.com/submissions/1317142676351/newpage/。我希望能够将该链接包含在我的邮件适配器模板之一中,但我不知道如何获取在自定义脚本适配器中生成的 uid,或者是否可能这样做。首先发生什么,是邮件程序还是自定义脚本适配器?
任何朝着正确方向的推动都将受到高度赞赏!
I have a PloneFormGen form with a Custom Script Adapter that, on form submission, generates a new uid and creates a folder with that uid as its ID.
from DateTime import DateTime
uid = str(DateTime().millis())
target.invokeFactory("Folder", id=uid, title=form['your-name'])
It uses input from the form to create various items in that folder, including a document called "newpage", which I then want to include a link to in an email. Is there a way to pass the uid variable from the script adapter to the mailer adapter, so that I can generate the link to the new documents inside the folder?
For instance, the script adapter creates a folder with the ID 1317142676351, so when the form is submitted, the URL for one of the new pages is http://mysite.com/submissions/1317142676351/newpage/. I want to be able to include that link in one of my Mailer Adapter templates, but I don't know how to get the uid that was generated in the Custom Script Adapter, or if that's even possible. What happens first, the Mailer, or the Custom Script Adapter?
Any push in the right direction is greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将 id 值复制到请求中即可。在脚本中,像这样的代码
就可以做到这一点。如果需要自动处理变量,请在表单中创建匹配的隐藏变量。
Just copy the id value to the request. In the script, code like:
will do it. If you need the variable to be automatically handled, create a matching hidden variable in the form.