Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Attributes
CMFDefault.RegistrationTool.RegistrationTool Class Reference
Collaboration diagram for CMFDefault.RegistrationTool.RegistrationTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def testPasswordValidity
def testPropertiesValidity
def mailPassword
def registeredNotify
def editMember

Static Public Attributes

string meta_type = 'Default Registration Tool'
tuple security = ClassSecurityInfo()

Private Member Functions

def _getValidEmailAddress

Static Private Attributes

 __implements__ = BaseTool.__implements__

Detailed Description

Manage through-the-web signup policies.

Definition at line 38 of file RegistrationTool.py.


Member Function Documentation

Definition at line 49 of file RegistrationTool.py.

00049 
00050     def _getValidEmailAddress(self, member):
00051         email = member.getProperty('email')
00052 
00053         # assert that we can actually get an email address, otherwise
00054         # the template will be made with a blank To:, this is bad
00055         if email is None:
00056             msg = _(u'No email address is registered for member: '
00057                     u'${member_id}', mapping={'member_id': member.getId()})
00058             raise ValueError(msg)
00059 
00060         checkEmailAddress(email)
00061         return email

Here is the caller graph for this function:

def CMFDefault.RegistrationTool.RegistrationTool.editMember (   self,
  member_id,
  properties = None,
  password = None,
  roles = None,
  domains = None,
  REQUEST = None 
)
Edit a user's properties and security settings

o Checks should be done before this method is called using
  testPropertiesValidity and testPasswordValidity

Definition at line 203 of file RegistrationTool.py.

00203 
00204                    roles=None, domains=None, REQUEST=None):
00205         """ Edit a user's properties and security settings
00206 
00207         o Checks should be done before this method is called using
00208           testPropertiesValidity and testPasswordValidity
00209         """
00210         # XXX: this method violates the rules for tools/utilities:
00211         # it depends on a non-utility tool
00212         mtool = getToolByName(self, 'portal_membership')
00213         member = mtool.getMemberById(member_id)
00214         member.setMemberProperties(properties)
00215         member.setSecurityProfile(password,roles,domains)
00216 
00217         return member
00218 
00219 InitializeClass(RegistrationTool)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFDefault.RegistrationTool.RegistrationTool.mailPassword (   self,
  forgotten_userid,
  REQUEST 
)
Email a forgotten password to a member.

o Raise an exception if user ID is not found.

Definition at line 130 of file RegistrationTool.py.

00130 
00131     def mailPassword(self, forgotten_userid, REQUEST):
00132         """ Email a forgotten password to a member.
00133 
00134         o Raise an exception if user ID is not found.
00135         """
00136         # XXX: this method violates the rules for tools/utilities:
00137         # it depends on a non-utility tool
00138         membership = getToolByName(self, 'portal_membership')
00139         member = membership.getMemberById(forgotten_userid)
00140 
00141         if member is None:
00142             raise ValueError(_(u'The username you entered could not be '
00143                                u'found.'))
00144 
00145         email = self._getValidEmailAddress(member)
00146 
00147         # Rather than have the template try to use the mailhost, we will
00148         # render the message ourselves and send it from here (where we
00149         # don't need to worry about 'UseMailHost' permissions).
00150         method = self.password_email
00151         kw = {'member': member, 'password': member.getPassword()}
00152 
00153         if getattr(aq_base(method), 'isDocTemp', 0):
00154             mail_text = method(self, REQUEST, **kw)
00155         else:
00156             mail_text = method(**kw)
00157 
00158         host = getUtility(IMailHost)
00159         host.send( mail_text )
00160 
00161         return self.mail_password_response( self, REQUEST )

Here is the call graph for this function:

def CMFDefault.RegistrationTool.RegistrationTool.registeredNotify (   self,
  new_member_id,
  password = None,
  REQUEST = None 
)
Handle mailing the registration / welcome message.

Definition at line 163 of file RegistrationTool.py.

00163 
00164     def registeredNotify(self, new_member_id, password=None, REQUEST=None):
00165         """ Handle mailing the registration / welcome message.
00166         """
00167         # XXX: this method violates the rules for tools/utilities:
00168         # it depends on a non-utility tool and uses self.REQUEST
00169         if REQUEST is None:
00170             REQUEST = self.REQUEST
00171             warn("registeredNotify should be called with 'REQUEST' as third "
00172                  "argument. The BBB code will be removed in CMF 2.3.",
00173                  DeprecationWarning, stacklevel=2)
00174 
00175         membership = getToolByName( self, 'portal_membership' )
00176         member = membership.getMemberById( new_member_id )
00177 
00178         if member is None:
00179             raise ValueError(_(u'The username you entered could not be '
00180                                u'found.'))
00181 
00182         if password is None:
00183             password = member.getPassword()
00184 
00185         email = self._getValidEmailAddress(member)
00186 
00187         # Rather than have the template try to use the mailhost, we will
00188         # render the message ourselves and send it from here (where we
00189         # don't need to worry about 'UseMailHost' permissions).
00190         method = self.registered_email
00191         kw = {'member': member, 'password': password, 'email': email}
00192 
00193         if getattr(aq_base(method), 'isDocTemp', 0):
00194             mail_text = method(self, REQUEST, **kw)
00195         else:
00196             mail_text = method(**kw)
00197 
00198         host = getUtility(IMailHost)
00199         host.send( mail_text )

Here is the call graph for this function:

def CMFDefault.RegistrationTool.RegistrationTool.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.

Definition at line 66 of file RegistrationTool.py.

00066 
00067     def testPasswordValidity(self, password, confirm=None):
00068 
00069         """ Verify that the password satisfies the portal's requirements.
00070 
00071         o If the password is valid, return None.
00072         o If not, return a string explaining why.
00073         """
00074         if not password:
00075             return _(u'You must enter a password.')
00076 
00077         if len(password) < 5 and not _checkPermission(ManagePortal, self):
00078             return _(u'Your password must contain at least 5 characters.')
00079 
00080         if confirm is not None and confirm != password:
00081             return _(u'Your password and confirmation did not match. '
00082                      u'Please try again.')
00083 
00084         return None

Here is the call graph for this function:

def CMFDefault.RegistrationTool.RegistrationTool.testPropertiesValidity (   self,
  props,
  member = None 
)
Verify that the properties supplied satisfy portal's requirements.

o If the properties are valid, return None.
o If not, return a string explaining why.

Definition at line 86 of file RegistrationTool.py.

00086 
00087     def testPropertiesValidity(self, props, member=None):
00088 
00089         """ Verify that the properties supplied satisfy portal's requirements.
00090 
00091         o If the properties are valid, return None.
00092         o If not, return a string explaining why.
00093         """
00094         if member is None: # New member.
00095 
00096             username = props.get('username', '')
00097             if not username:
00098                 return _(u'You must enter a valid name.')
00099 
00100             if not self.isMemberIdAllowed(username):
00101                 return _(u'The login name you selected is already in use or '
00102                          u'is not valid. Please choose another.')
00103 
00104             email = props.get('email')
00105             if email is None:
00106                 return _(u'You must enter an email address.')
00107 
00108             try:
00109                 checkEmailAddress(email)
00110             except ValidationError:
00111                 return _(u'You must enter a valid email address.')
00112 
00113         else: # Existing member.
00114             email = props.get('email')
00115 
00116             if email is not None:
00117                 try:
00118                     checkEmailAddress(email)
00119                 except ValidationError:
00120                     return _(u'You must enter a valid email address.')
00121 
00122             # Not allowed to clear an existing non-empty email.
00123             existing = member.getProperty('email')
00124 
00125             if existing and email == '':
00126                 return _(u'You must enter a valid email address.')
00127 
00128         return None

Here is the call graph for this function:


Member Data Documentation

CMFDefault.RegistrationTool.RegistrationTool.__implements__ = BaseTool.__implements__ [static, private]

Definition at line 43 of file RegistrationTool.py.

string CMFDefault.RegistrationTool.RegistrationTool.meta_type = 'Default Registration Tool' [static]

Definition at line 45 of file RegistrationTool.py.

tuple CMFDefault.RegistrationTool.RegistrationTool.security = ClassSecurityInfo() [static]

Definition at line 47 of file RegistrationTool.py.


The documentation for this class was generated from the following file: