Changeset 9312


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

Import roles correctly.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
3 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):
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/batchprocessing.txt

    r9310 r9312  
    2323    >>> from waeup.kofa.app import University
    2424    >>> getRootFolder()['app'] = University()
     25    >>> from zope.component.hooks import setSite
     26    >>> setSite(getRootFolder()['app'])
    2527
    2628Create a datacenter storage path:
     
    493495   >>> henrik = getRootFolder()['app']['users']['henrik']
    494496   >>> henrik.roles
    495    ['waeup.PortalManager', 'waeup.ImportManager']
     497   ['waeup.PortalManager', 'waeup.AcademicsOfficer', 'waeup.ImportManager']
    496498
    497499Pending files
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/batching.py

    r9307 r9312  
    7575                evalvalue = eval(value)
    7676                if isinstance(evalvalue, list):
    77                     value = eval(value)
     77                    value = evalvalue
    7878            except:
    7979                pass
Note: See TracChangeset for help on using the changeset viewer.