Ignore:
Timestamp:
8 Oct 2012, 07:54:23 (12 years ago)
Author:
Henrik Bettermann
Message:

Import roles correctly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/authentication.py

    r8973 r9312  
    3737    IUserAccount, IAuthPluginUtility, IPasswordValidator,
    3838    IKofaPrincipal, IKofaPrincipalInfo, IKofaPluggable,
    39     IBatchProcessor)
     39    IBatchProcessor, IGNORE_MARKER)
    4040from waeup.kofa.utils.batching import BatchProcessor
    4141
     
    420420        return
    421421
     422    def updateEntry(self, obj, row, site):
     423        """Update obj to the values given in row.
     424        """
     425        changed = []
     426        for key, value in row.items():
     427            if  key == 'roles':
     428                # We cannot simply set the roles attribute here because
     429                # we can't assure that the name attribute is set before
     430                # the roles attribute is set.
     431                continue
     432            # Skip fields to be ignored.
     433            if value == IGNORE_MARKER:
     434                continue
     435            if not hasattr(obj, key):
     436                continue
     437            setattr(obj, key, value)
     438            changed.append('%s=%s' % (key, value))
     439        roles = row.get('roles', IGNORE_MARKER)
     440        if roles not in ('', IGNORE_MARKER):
     441            evalvalue = eval(roles)
     442            if isinstance(evalvalue, list):
     443                setattr(obj, 'roles', evalvalue)
     444                changed.append('roles=%s' % roles)
     445        # Log actions...
     446        items_changed = ', '.join(changed)
     447        grok.getSite().logger.info('%s - %s - User updated: %s'
     448            % (self.name, row['name'], items_changed))
     449        return
    422450
    423451class UsersPlugin(grok.GlobalUtility):
Note: See TracChangeset for help on using the changeset viewer.