[Zope-CMF] Batch member creation

Ausum Studio ausum_studio@hotmail.com
Wed, 21 Aug 2002 18:02:57 -0500


After digging into the external method that Tres posted a time ago, I came
to try this method (external):

def createmember(self):
    from Products.CMFCore.utils import getToolByName
    rt = getToolByName( self, 'portal_registration' )
    rt.addMember( 'testuser', 'demopass'
                , properties={ 'lastname' : 'Last Name'
                             , 'email' : 'asd@asd.com'
                             , 'firstname' : 'First Name'
                             } )
    return "done"

Provided 'lastname' and 'firstname' were previosuly created at
portal_memberdata this should have worked, except for what I've found it'd
be a bug within the default RegistrationTool.py. I didn't have time to
analize what happens, so commenting out the lines below did the job, at
least while performing the batch. Starting from line 100:

    def 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.
        """
        print props
##        if member is None: # New member.
##            username = props.get('username', '')
##            if not username:
##                return 'You must enter a valid name.'
##            if not self.isMemberIdAllowed(username):
##                raise ('The login name you selected is already '
##                       'in use or is not valid. Please choose another.')
##
##            if not props.get('email'):
##                return 'You must enter a valid email address.'
##
##        else: # Existing member.
##            # Not allowed to clear an existing non-empty email.
##            if (member.getProperty('email') and
##                not props.get('email', 'NoPropIsOk')):
##                return 'You must enter a valid email address.'
        return None

Can someone point out what's wrong with it?

Thanks,



Ausum