Changeset 263 for trunk/web


Ignore:
Timestamp:
Jan 29, 2008, 11:35:48 PM (17 years ago)
Author:
ecprice
Message:

Modularize cache_acls.py yet more

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/cache_acls.py

    r262 r263  
    3131    return getafsgroups.getAfsGroupMembers(name, 'athena.mit.edu')
    3232
     33def refreshMachine(m):
     34    people = set()
     35    people.update(expandLocker(m.owner))
     36    people.update(expandName(m.administrator))
     37    old_people = set(a.user for a in m.acl)
     38    for removed in old_people - people:
     39        ma = [x for x in m.acl if x.user == removed][0]
     40        ctx.current.delete(ma)
     41    for p in people - old_people:
     42        ma = MachineAccess(machine_id=m.machine_id, user=p)
     43        ctx.current.save(ma)
     44   
    3345def refreshCache():
    3446    transaction = ctx.current.create_transaction()
     
    3749        machines = Machine.select()
    3850        for m in machines:
    39             people = set()
    40             people.update(expandLocker(m.owner))
    41             people.update(expandName(m.administrator))
    42             print '%s: %s' % (m.name, ' '.join(people))
    43             old_people = set(a.user for a in m.acl)
    44             for removed in old_people - people:
    45                 ma = [x for x in m.acl if x.user == removed][0]
    46                 ctx.current.delete(ma)
    47             for p in people - old_people:
    48                 ma = MachineAccess(machine_id=m.machine_id, user=p)
    49                 ctx.current.save(ma)
    50             ctx.current.flush()
     51            refreshMachine(m)
     52        ctx.current.flush()
    5153           
    5254        # Atomically execute our changes
Note: See TracChangeset for help on using the changeset viewer.