hi,
i am doing a validation for joining form .
when i write the code in python script -
## Script (Python) "join_form_validate"
-
##bind container=container
-
##bind context=context
-
##bind namespace=
-
##bind script=script
-
##bind state=state
-
##bind subpath=traverse_subpath
-
##parameters=username='',email='',password='',password_confirm=''
-
##title=validates the Registration of a User
-
##
-
from Products.CMFPlone import PloneMessageFactory as _
-
-
reg_tool=context.portal_registration
-
def missing(field):
-
state.setError(field, _(u'This field is required, please provide some information.'), 'input_required')
-
def nomatch(field):
-
state.setError(field, _(u'Passwords do not match.'), 'nomatch_password')
-
def minlimit(field):
-
state.setError(field, _(u'Passwords must contain at least 5 letters.'), 'min_password')
-
def notallowed(field):
-
state.setError(field, _(u'This username is reserved. Please choose a different name.'), 'not_allowed')
-
-
if not username:
-
missing('username')
-
if not email:
-
missing('email')
-
if username and username == context.portal_url.getPortalObject().getId():
-
notallowed('username')
-
-
properties = context.portal_properties.site_properties
-
if not properties.validate_email:
-
if password!=password_confirm:
-
nomatch('password')
-
nomatch('password_confirm')
-
-
if not password:
-
missing('password')
-
if not password_confirm:
-
missing('password_confirm')
-
-
if not state.getError('password') and len(password) < 5:
-
minlimit('password')
-
minlimit('password_confirm')
-
-
if not state.getError('username') and not reg_tool.isMemberIdAllowed(username):
-
state.setError('username',
-
_(u'The login name you selected is already in use or is not valid. Please choose another.'),
-
'username_invalid' )
-
-
if state.getErrors():
-
context.plone_utils.addPortalMessage(_(u'Please correct the indicated errors.'))
-
return state.set(status='failure')
-
else:
-
context.plone_utils.addPortalMessage(_(u'You have been registered.'))
-
return state
-
the error is
Error Type:
KeyError
Error Value:
'bind state
1 1114
I don't see the import for context.. What module is that name coming from?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: raj |
last post by:
hi,
i have one textbox and one save button, i have added attribute at page
load event
btnSave.Attributes.Add("onclick","return ValidateForm();");
in validationform() ,I have written like this...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |