Getting ploneformgen methods and attributes

We need to solve this problem. A user logs in with PloneFormGen, fills out the form to register, and submits it. If the user tries to register again, we want to prevent it and show them a message telling them they have already registered. This is open to the public. Users don't have an id we can use.

One solution is to take data that was just submitted from the first and last name and compare it with what is in the save data adapter. If both are found, then the user get the message. If not, it goes on through and registers them. I tried using this code I found on line, but get an error:

alreadyInDB = False
savedData = ploneformgen.savefield.getSavedFormInputForEdit()
username = request.AUTHENTICATED_USER.getId()
return {'username': 'No way man!'}
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!'}
<<<

This is the error message I get.

AttributeError: savefield

What I want to do is see what is available for attributes and methods and either fix this or write my own. Any help is appreciated. Also, if you have a better way of doing this, let me know. I would still like to know how to get the methods and attributes, but solving the problem needs to come first.

This is what we use: PloneFormGen 1.7.12 Products.PFGExtendedMailAdapter 2.4

Plone 4.3.3 (4308) CMF 2.2.7 Zope 2.13.22 Python 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] PIL 2.0.0 (Pillow)

Thanks,

You have no (reliable) chance when the user registers with different information (e.g. another email address or login name). When he uses the same information, you should be able to detect this and reject the registration.

I am a bit confused here. Has the user logged in ? with FormGen ?

Or do you mean that they have logged in on the site and you have a PloneFormGen form to register for 'some activity' ?

What exactly is plonformgen defined or where is this coming from?
Same with savefield? Is this the save adapter?
Where/how do you invoke the given script ?

I know that is part of the problem, but this is open to the public. Since I can't guarantee they won't register again, all I can do is check their names and their email addresses. If either is a duplicate in the saved data adapter, then I would return the message that they have already registered. I would like to run the script via a Plone Script Adapter, but I don't know if that is possible due to limitations on Pyton code that can be be used ("Restricted Pyton") The code I submitted is from this page:

https://stackoverflow.com/questions/20923149/python-script-to-hide-ploneformgen-form-after-user-has-filled-it-out-for-plone.

The form I built is at https://ed.psu.edu/pds/teacher-inquiry/teacher-inquiry-conference-registration
The user fills it out and submits it. They get an email and are taken to a Thank You Page. The data is stored in a saved data adapter. The person handling the site also gets an email and has access to the data in the saved data adapter.

I would also like to list the methods and attributes available in PloneFormGen so I can choose them for this script and others in the future. I though a lot of people would be interested in this so I posted
it here.

I dont think your approach is going to work. The link you posted is from someone that already have the users logged in, and from what I understand, this is not the case for you.

What you try to do is quite simple if you make a custom form, but I dont think anyone would put much effort into doing this with FormGen, since it will 'disappear' in future versions of Plone (it will not be ported to Python 3 (I think))

PloneFormGen is based on Archetypes technology which will not be supported in Python 3. collective.easyform is the dexterity equivalent to PFG and is already ported to Py3 ...