source: products/qPloneCaptchas/trunk/skins/captchas_join_form/2.5/register.cpy @ 241

Last change on this file since 241 was 3, checked in by crchemist, 19 years ago

initial import

  • Property svn:eol-style set to native
File size: 2.6 KB
Line 
1## Controller Python Script "register"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind state=state
7##bind subpath=traverse_subpath
8##parameters=password='password', password_confirm='password_confirm', came_from_prefs=None
9##title=Register a User
10##
11
12from Products.CMFPlone import PloneMessageFactory as _
13from ZODB.POSException import ConflictError
14
15REQUEST = context.REQUEST
16
17portal_registration = context.portal_registration
18site_properties = context.portal_properties.site_properties
19
20username = REQUEST['username']
21
22password=REQUEST.get('password') or portal_registration.generatePassword()
23
24# This is a temporary work-around for an issue with CMF not properly
25# reserving some existing ids (FSDV skin elements, for example). Until
26# this is fixed in the CMF we can at least fail nicely. See
27# http://dev.plone.org/plone/ticket/2982 and http://plone.org/collector/3028
28# for more info. (rohrer 2004-10-24)
29try:
30    try:
31        portal_registration.addMember(username, password, properties=REQUEST, REQUEST=context.REQUEST)
32    except TypeError:
33        portal_registration.addMember(username, password, properties=REQUEST)
34except AttributeError:
35    state.setError('username', _(u'The login name you selected is already in use or is not valid. Please choose another.'))
36    context.plone_utils.addPortalMessage(_(u'Please correct the indicated errors.'))
37    return state.set(status='failure')
38
39if site_properties.validate_email or REQUEST.get('mail_me', 0):
40    try:
41        portal_registration.registeredNotify(username)
42    except ConflictError:
43        raise
44    except Exception, err:
45
46        # TODO registerdNotify calls into various levels.  Lets catch all
47        # exceptions.  Should not fail.  They cant CHANGE their password ;-)
48        # We should notify them.
49        #
50        # (MSL 12/28/03) We also need to delete the just made member and return to the join_form.
51        msg = _(u'We were unable to send your password to your email address: ${address}',
52                mapping={u'address' : str(err)})
53        state.setError('email', msg)
54        state.set(came_from='login_success')
55        context.acl_users.userFolderDelUsers([username,],REQUEST=context.REQUEST)
56        context.plone_utils.addPortalMessage(_(u'Please enter a valid email address.'))
57        return state.set(status='failure')
58
59state.set(came_from=REQUEST.get('came_from','login_success'))
60
61if came_from_prefs:
62    context.plone_utils.addPortalMessage(_(u'User added.'))
63    state.set(status='prefs')
64
65from Products.CMFPlone import transaction_note
66transaction_note('%s registered' % username)
67
68return state
Note: See TracBrowser for help on using the repository browser.