Logo Search packages:      
Sourcecode: zope-cmfldap version File versions

def CMFLDAP::LDAPMemberDataTool::LDAPMemberDataTool::wrapUser (   self,

If possible, returns the Member object that corresponds
to the given User object.

Definition at line 35 of file LDAPMemberDataTool.py.

00035                          :
        If possible, returns the Member object that corresponds
        to the given User object.
        id = u.getUserName()
        members = self._members

        if not members.has_key(id):
            # Get a temporary member that might be
            # registered later via registerMemberData().
            temps = self._v_temps

            if temps is not None and temps.has_key(id):
                m = temps[id]
                base = aq_base(self)
                m    = LDAPMemberData(base, id)

                if temps is None:
                    self._v_temps = { id : m }
                    temps[id] = m
            m = members[id]

        wrapper = m.__of__(self).__of__(u)
        # We set the MemberData global options if we found values
        # in the UserData. (for instance the 'email')
            global mapped_attrs
            mapped_attrs = self.acl_users.getMappedUserAttrs()

            for MappedUserAttr in mapped_attrs:
                    # get the property value from LDAPUser object, if it is 
                    # empty then the method will raise an exception
                    PropertyValue = u.getProperty(MappedUserAttr[1])
                    # now read the value from the wrapper
                    WrapperPropertyValue = wrapper.getProperty(MappedUserAttr[1])
                    # redefine the wrapper value if it differ
                    if ( PropertyValue is not None and 
                         PropertyValue != '' and 
                         PropertyValue != WrapperPropertyValue ):
                        setattr(wrapper, MappedUserAttr[1], PropertyValue)
                    # the exception may be thrown if PropertyValue is empty

        # Return a wrapper with self as containment and
        # the user as context.
        return wrapper

    def getMemberDataContents(self):

Generated by  Doxygen 1.6.0   Back to index