Is there a way to pass PloneFormGen form data to an external site with post request in custom script adapter?
My external site is visible only by server
url for post is http://app.com/issues_form/issues
My script in custom stript adapter:
import urllib
import urllib2
url = "http://app.com/issues_form/issues"
values = {'issue' : request.form['issue'] }
data = urllib.urlencode(values)
urllib2.Request(url,data)
When submitting I get unauthorized access or something with permissions
http://ploneapp.com/acl_users/credentials_cookie_auth/require_login?came_from=http%3A/ploneapp.com/structure/test/issue_form
It seems the errors happens when I use urllib.urlencode.
It is the same when I try to use another way with 'requests' library. Maybe I cant access such libraries in such places.
This is not possible via the custom script adapter unless you bypass some security — which is inadvisable. The problem is that the urllib and urllib2 libraries have not been marked as "safe" in restricted Python. "Restricted Python" is the subset of Python available for TTW scripting.
If you need to do something like this, you'll need to add a file system product, probably a browser view. You'll find examples of packages that do this with PFG input in the products section of Plone.Org. Most are concerned with external payment or membership systems. You'll find they deal with a lot of thorny issues, like threading and timeouts, to make sure that Plone is not tied up waiting for a post to process.