Plone: Pass a variable from PloneFormGen Custom Script Adapter to Mailer Adapter
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 开发者_如何学Cwhen 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!
Just copy the id value to the request. In the script, code like:
request.set('custom_id', id)
will do it. If you need the variable to be automatically handled, create a matching hidden variable in the form.
精彩评论