source: products/qPloneCaptchas/trunk/skins/captchas_join_form/2.0.5/register.cpy @ 2284

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

initial import

  • Property svn:eol-style set to native
File size: 2.3 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', confirm='confirm', came_from_prefs=None
9##title=Register a User
10##
11from ZODB.POSException import ConflictError
12
13REQUEST=context.REQUEST
14
15portal_registration=context.portal_registration
16site_properties=context.portal_properties.site_properties
17
18username = REQUEST['username']
19
20password=REQUEST.get('password') or portal_registration.generatePassword()
21
22# This is a temporary work-around for an issue with CMF not properly
23# reserving some existing ids (FSDV skin elements, for example). Until
24# this is fixed in the CMF we can at least fail nicely. See
25# http://plone.org/collector/2982 and http://plone.org/collector/3028
26# for more info. (rohrer 2004-10-24)
27try:
28    portal_registration.addMember(username, password, properties=REQUEST)
29except AttributeError:
30    state.setError('username', 'The login name you selected is already in use or is not valid. Please choose another.')
31    return state.set(status='failure', portal_status_message='Please correct the indicated errors.')
32
33if site_properties.validate_email or REQUEST.get('mail_me', 0):
34    try:
35        portal_registration.registeredNotify(username)
36    except ConflictError:
37        raise
38    except Exception, err:
39
40        #XXX registerdNotify calls into various levels.  Lets catch all exceptions.
41        #    Should not fail.  They cant CHANGE their password ;-)  We should notify them.
42        #
43        # (MSL 12/28/03) We also need to delete the just made member and return to the join_form.
44               
45        state.setError('email', 'We were unable to send your password to your email address: '+str(err))
46        state.set(came_from='logged_in')
47        context.acl_users.userFolderDelUsers([username,])
48        return state.set(status='failure', portal_status_message='Please enter a valid email address.')
49       
50state.set(portal_status_message=REQUEST.get('portal_status_message', 'Registered.'))
51state.set(came_from=REQUEST.get('came_from','logged_in'))
52
53if came_from_prefs:
54    state.set(status='prefs')
55
56from Products.CMFPlone import transaction_note
57transaction_note('%s registered' % username)
58
59return state
Note: See TracBrowser for help on using the repository browser.