Python script to hide ploneformgen form after user has filled it out. (For Plone-4.3.2-64.)

After a user has filled out a (ploneformgen) form , I would like to use a custom script adapter to call a python script to change the user’s local role so that they can’t see the form anymore. In other words, I want to prevent the user from filling out (or viewing) the form twice.

I figured that one way to do this is to call the script which is located in the form folder. The code I have in that script is this:


Where ‘bob’ is just an example user, who has only the global role FormFiller (which I created under the Security tab of the ZMI) and the local role "Reader" for the form folder.

When I fill out the form (which has a "private" state) as a system admin, the script is called successfully and bob loses his "Reader" local role (which is all he had to begin with), and he can’t see the form anymore. However, when bob fills out the form, a "You do not have sufficient privileges to view this page." error is displayed, and bob’s local role is not removed. I can’t work out why –– and I’ve tried many different things:

I’ve changed the proxy for the by clicking on "Proxy" tab for the script in ZMI. I changed it to "Manager", "System Administrator", and "Owner", but that didn’t solve the problem (nor did any combination of those).

I tried changing the proxy by creating a file in the form folder and including this:

 proxy = Manager

but that didn’t work either.

Strangely, when I change bob’s global role to Manager, or System Administrator, or even Viewer, or Editor, the problem goes away and the script runs just fine (I can also change the script so that it adds and removes arbitrary other local roles). (These options are not solutions for me because bob will still be able to see the form because of his global role.)

Also, I tried giving the role FormFiller role every possible permission under the Security tab, but didn’t work.

So, I’m guessing that the problem has to do with the proxy settings, but I can’t work out what I’m doing wrong. I've searched around a lot, and I can't find anyone discussing a similar problem.

Any help would be much appreciated!

Ugly ugly way to handle this may be to access to the data saver field's download method and parse its output to find data to check. For example, if username is the second pfg field added into form, a custom script adapter that prevents furthers fillings by a user may be

alreadyInDB = False
savedData = ploneformgen.savefield.getSavedFormInputForEdit()
username = request.AUTHENTICATED_USER.getId()

usersInDB = [x.split(',')[1] for x in savedData.split('\r\n') if len(x)>0]

if username in usersInDB:
    alreadyInDB = True

if alreadyInDB:
    return {'username': 'No way man!'}

How do you determine what attributes and methods are available in , from: Python script to hide ploneformgen form after user has filled it out. (For Plone-4.3.2-64.) PloneFormGen uses restricted Python for the TTW scripts. You can use dir() or vars() on your objects to find out what they offer. to get the Form and use the real debugger there with the same methods from� If so, Python can help you automate most of these tedious tasks. Join me on this journey to learn how a simple Python script can automate online data-entry. Yes, you can use Python to automatically fill out a form online. Download the Completed Project Before we begin, here is the completed Python script, as well as the web form I’ll reference.

I worked out what was going on, but I'm not sure how to describe it precisely. Basically, I found that by calling the script as a Custom Success Action (form > edit > overrides), I don't get the problem. So I think that by calling the script as custom script adapter I was trying to change the user's permission while they were still engaged with the form and that is impossible, even with the Manager proxy role.

I hope that helps. And if anyone has a more precise description of the problem, that would be appreciated.

python, 用户填写了ploneformgen 表单后,我想使用自定义脚本适配器来调用python脚本以更改用户的本地角色,以使他们不再能看到该表单。 换句话说,我要 对于Plone- 4.3.2-64。) Python script to hide ploneformgen form after user has filled it out. If you wish to encrypt a python script, without having to do any work on your end, you can do so using this site. I tested the following script using the aforementioned site and it produced a very intimidating output, which worked (at least for my purposes):

For granting and revoking the permissions to submit a form, you could:

  1. Create a group (e.g. with the ID "Submitters") and assign the chosen users to it
  2. Make sure the form-folder has the state 'private' and grant View-permissions via the sharing-tab of the form-folder to the group
  3. Add a content-item of type 'Page' in the form-folder's parent (e.g. with the ID 'submitted') and set its state to 'public'
  4. Add a content-item of type 'Custom Script Adapter', select 'Manager' in the field 'Proxy role', and insert the lines below into the field 'Script body':
# Remove current user of group and redirect to [FORM_PARENT_URL]/landing_page_id'.
# If user is not in group, fail silently and continue.
# Fail if landing_page_id does not exist in form-folder, or one of its parents.
# Assumes a page with the ID as declared in `landing_page_id` lives in the
# form-folder's parent (or one of its grand-parents, first found wins),
# and holds the state 'public', so users can view it regardless of their
# group-memberships.
# Ment to be used after submission of a PloneFormGen-form with private-state and
# a locally assigned Reader-role for the group, so only group-members can view and
# submit the form.

from Products.CMFCore.utils import getToolByName

group_id = 'Submitters' # change as needed

landing_page_id = 'submitted' # change as needed

portal_groups = getToolByName(ploneformgen, 'portal_groups')

user_id = ploneformgen.memberId()

parent_url = '/'.join(ploneformgen.absolute_url().split('/')[:-1])

redirect_to_url = parent_url + '/' + landing_page_id

# Revoke current user's group-membership:
portal_groups.removePrincipalFromGroup(user_id, group_id)

# Let user land in userland:

Tested with Plone-4.3.11 and Products.PloneFormGen-1.7.25

python, 知道可用的脚本。我的直接问题来自我从以下网站复制的一些在线代码: Python script to hide ploneformgen form after user has filled it out. (For Plone-4.3.2-64.) simple_form.pdf,,, 1,first name,Mike 2,last name,Driscoll Once you have the CSV filled out, you can run the following command to actually fill your form out with your custom data: pdfforms fill data.csv The filled PDF will appear in a sub-folder called filled by default. Now on to the bad news.

Umbraco 7.7.3 Programmatically set password for a new User , I am programmatically creating users (not members!) in umbraco 7.7.3 using the UmbracoContext.Application.Services. Python script to hide ploneformgen form after user has filled it out. (For Plone-4.3.2-64.) After a user has filled out a� Today we’ll spend some time looking at three different ways to make Python submit a web form. In this case, we will be doing a web search with searching on the term “python” and saving the result as an HTML file. We will use Python’s included urllib modules and two 3rd party packages: requests … Continue reading Python 101: How to submit a web form →

Check if user is in group by group name - laravel-4 - Python, I see that there is a inGroup() function on the user, but this requires that you first fetch the group object, and pass it into the function, rather than simply Python script to hide ploneformgen form after user has filled it out. (For Plone-4.3.2-64.). Effective Python — insight into the Pythonic way of writing programs. Fluent Python — takes you through Python’s core language features and libraries, and shows you how to make your code shorter, faster, and more readable at the same time. Fluent Python, 2nd Edition. Serious Python — deployment, scalability, testing, and more

Script Python pour masquer le formulaire ploneformgen apr�s l'avoir , Une fois qu'un utilisateur a rempli un formulaire (ploneformgen), j'aimerais utiliser un adaptateur de script personnalis� pour appeler un script python afin de modifier le r�le local de l'utilisateur afin qu'il ne puisse plus (Pour Plone-4.3.2- 64.)� Most systems come pre-installed with Python 2.7. While Python 2.7 is used in legacy code, Python 3 is the present and future of the Python language. Unless you have a specific reason to write or support Python 2, we recommend working in Python 3. For Microsoft Windows, Python 3 can be downloaded from the Python official website. When installing

  • Your actions seems ok to me, so I suggest you to debug what is the real problem. Please check… and temporarily disable the "Unauthorized" exception swallowed by the error_log
  • Same problem. It seems that the exception is raised accessing at the generator object that wrap saved data. Because we are managing a "custom script adapter" we are in the "restricted python" environment and accessing that type of object is denied even if you are Manager. Proxy role does not affect this type of restrictions. The exception is something like: """Unauthorized: The container has no security assertions. Access to None of (generator object inputAsDictionaries at 0xb3201874) denied."""
  • When deleting a role via a custom-script-adapter (with the field 'Proxy-role: Manager' checked, not set via a metadata-file), I get Unauthorized: You are not allowed to access 'fgGetSuccessAction' in this context .