Changeset 7104


Ignore:
Timestamp:
13 Nov 2011, 14:30:44 (13 years ago)
Author:
uli
Message:

Tiny cleanups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r6918 r7104  
    4747
    4848def add_local_role(view, tab, **data):
    49     form = view.request.form
    50     localrole = form['local_role']
    51     if form.has_key('user'):
    52         user = form['user']
    53     else:
     49    localrole = view.request.form.get('local_role', None)
     50    user = view.request.form.get('user', None)
     51    if user is None or localrole is None:
    5452        view.flash('No user selected.')
    5553        view.redirect(view.url(view.context, '@@manage')+'#tab-%s' % tab)
     
    5856    role_manager.assignRoleToPrincipal(localrole, user)
    5957    notify(LocalRoleSetEvent(view.context, localrole, user, granted=True))
    60     #import pdb; pdb.set_trace()
    6158    view.redirect(view.url(view.context, u'@@manage')+'#tab-%s' % tab)
    6259    return
    6360
    6461def del_local_roles(view, tab, **data):
    65     form = view.request.form
    66     if form.has_key('role_id'):
    67         child_id = form['role_id']
    68     else:
     62    child_ids = view.request.form.get('role_id', None)
     63    if child_ids is None:
    6964        view.flash('No local role selected.')
    7065        view.redirect(view.url(view.context, '@@manage')+'#tab-%s' % tab)
    7166        return
    72     if not isinstance(child_id, list):
    73         child_id = [child_id]
     67    if not isinstance(child_ids, list):
     68        child_ids = [child_ids]
    7469    deleted = []
    7570    role_manager = IPrincipalRoleManager(view.context)
    76     for id in child_id:
    77         localrole = id.split('|')[1]
    78         user_name = id.split('|')[0]
     71    for child_id in child_ids:
     72        localrole = child_id.split('|')[1]
     73        user_name = child_id.split('|')[0]
    7974        try:
    8075            role_manager.unsetRoleForPrincipal(localrole, user_name)
    81             notify(LocalRoleSetEvent(view.context, localrole, user_name, granted=False))
    82             deleted.append(id)
     76            notify(LocalRoleSetEvent(
     77                    view.context, localrole, user_name, granted=False))
     78            deleted.append(child_id)
    8379        except:
    8480            view.flash('Could not remove %s: %s: %s' % (
    85                     id, sys.exc_info()[0], sys.exc_info()[1]))
     81                    child_id, sys.exc_info()[0], sys.exc_info()[1]))
    8682    if len(deleted):
    8783        view.flash('Successfully removed: %s' % ', '.join(deleted))
Note: See TracChangeset for help on using the changeset viewer.