[CMF-checkins] CVS: CMF/CMFDefault - RegistrationTool.py:1.22

Yvo Schubbe cvs-admin at zope.org
Tue Oct 28 08:49:47 EST 2003


Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv17093/CMFDefault

Modified Files:
	RegistrationTool.py 
Log Message:
- merged change from CMFHotfix_20031026
- unified error handling
- whitespace cleanup


=== CMF/CMFDefault/RegistrationTool.py 1.21 => 1.22 ===
--- CMF/CMFDefault/RegistrationTool.py:1.21	Mon Sep  1 11:18:36 2003
+++ CMF/CMFDefault/RegistrationTool.py	Tue Oct 28 08:49:45 2003
@@ -26,9 +26,9 @@
 from Products.CMFCore.RegistrationTool import RegistrationTool as BaseTool
 from Products.CMFCore.CMFCorePermissions import AddPortalMember
 from Products.CMFCore.CMFCorePermissions import ManagePortal
-
 from utils import _dtmldir
 
+
 class RegistrationTool(BaseTool):
     """ Manage through-the-web signup policies.
     """
@@ -60,7 +60,7 @@
                      + ( { 'label' : 'Overview'
                          , 'action' : 'manage_overview'
                          }
-                       , 
+                       ,
                        )
                      )
     manage_overview = DTMLFile( 'explainRegistrationTool', _dtmldir )
@@ -72,7 +72,7 @@
     def testPasswordValidity(self, password, confirm=None):
 
         """ Verify that the password satisfies the portal's requirements.
-        
+
         o If the password is valid, return None.
         o If not, return a string explaining why.
         """
@@ -80,7 +80,7 @@
             return 'Your password must contain at least 5 characters.'
 
         if confirm is not None and confirm != password:
-            return ( 'Your password and confirmation did not match. ' 
+            return ( 'Your password and confirmation did not match. '
                    + 'Please try again.' )
 
         return None
@@ -116,22 +116,21 @@
 
     security.declarePublic( 'mailPassword' )
     def mailPassword(self, forgotten_userid, REQUEST):
-
         """ Email a forgotten password to a member.
-        
+
         o Raise an exception if user ID is not found.
         """
         membership = getToolByName(self, 'portal_membership')
         member = membership.getMemberById(forgotten_userid)
 
         if member is None:
-            raise ValueError, 'The username you entered could not be found.'
-    
+            raise ValueError('The username you entered could not be found.')
+
         # assert that we can actually get an email address, otherwise
         # the template will be made with a blank To:, this is bad
         if not member.getProperty('email'):
-            raise ValueError, 'That user does not have an email address.'
-        
+            raise ValueError('That user does not have an email address.')
+
         # Rather than have the template try to use the mailhost, we will
         # render the message ourselves and send it from here (where we
         # don't need to worry about 'UseMailHost' permissions).
@@ -140,7 +139,7 @@
                                                , member=member
                                                , password=member.getPassword()
                                                )
-    
+
         host = self.MailHost
         host.send( mail_text )
 
@@ -148,17 +147,22 @@
 
     security.declarePublic( 'registeredNotify' )
     def registeredNotify( self, new_member_id ):
-
         """ Handle mailing the registration / welcome message.
         """
         membership = getToolByName( self, 'portal_membership' )
         member = membership.getMemberById( new_member_id )
 
         if member is None:
-            raise 'NotFound', 'The username you entered could not be found.'
+            raise ValueError('The username you entered could not be found.')
 
         password = member.getPassword()
-    
+
+        email = member.getProperty( 'email' )
+
+        if email is None:
+            raise ValueError( 'No email address is registered for member: %s'
+                            % new_member_id )
+
         # Rather than have the template try to use the mailhost, we will
         # render the message ourselves and send it from here (where we
         # don't need to worry about 'UseMailHost' permissions).
@@ -166,8 +170,9 @@
                                                    , self.REQUEST
                                                    , member=member
                                                    , password=password
+                                                   , email=email
                                                    )
-    
+
         host = self.MailHost
         host.send( mail_text )
 
@@ -186,7 +191,7 @@
         o Checks should be done before this method is called using
           testPropertiesValidity and testPasswordValidity
         """
-        
+
         mtool = getToolByName(self, 'portal_membership')
         member = mtool.getMemberById(member_id)
         member.setMemberProperties(properties)




More information about the CMF-checkins mailing list