Logo Search packages:      
Sourcecode: zope-cmfldap version File versions

register.py

## Script (Python) "register"
##title=Register a user
##bind namespace=_
##parameters=password='password', confirm='confirm'
REQUEST=context.REQUEST
portal_membership = context.portal_membership
portal_properties = context.portal_properties
portal_registration = context.portal_registration

if REQUEST.get('email', '') == '':
    if REQUEST.has_key('mail'):
        email_addr = REQUEST.get( 'mail' )
    else:
        email_addr = ''

    REQUEST.set('email', email_addr)

if not portal_properties.validate_email:
  failMessage = portal_registration.testPasswordValidity(password, confirm)
  if failMessage:
      REQUEST.set('error', failMessage)
      return context.join_form(context, REQUEST, error=failMessage)

failure = portal_membership.memberExists(REQUEST)
if failure:
    failMessage = 'A member with this %s already exists.' % failure
    REQUEST.set('error', failMessage)
    return context.join_form(context, REQUEST, error=failMessage)
    
      
failMessage = portal_registration.testPropertiesValidity(REQUEST)

if failMessage:
    REQUEST.set('error', failMessage)
    return context.join_form(context, REQUEST, error=failMessage)

else:
    password=REQUEST.get('password') or portal_registration.generatePassword()
    portal_registration.addMember( REQUEST['username']
                                 , password
                                 , properties=REQUEST
                                 )

    if portal_properties.validate_email or REQUEST.get('mail_me', 0):
        portal_registration.registeredNotify(REQUEST['username'])

    return context.registered(context, REQUEST)

Generated by  Doxygen 1.6.0   Back to index