From 8b2c8fa5de64487465829fee603e4c304ed9f9cc Mon Sep 17 00:00:00 2001 From: Eric Price Date: Tue, 29 Jan 2008 23:35:48 -0500 Subject: [PATCH] Modularize cache_acls.py yet more svn path=/trunk/web/; revision=263 --- cache_acls.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/cache_acls.py b/cache_acls.py index c7484d0..34d5e1e 100644 --- a/cache_acls.py +++ b/cache_acls.py @@ -30,24 +30,26 @@ def expandName(name): name = 'system:'+name return getafsgroups.getAfsGroupMembers(name, 'athena.mit.edu') +def refreshMachine(m): + people = set() + people.update(expandLocker(m.owner)) + people.update(expandName(m.administrator)) + old_people = set(a.user for a in m.acl) + for removed in old_people - people: + ma = [x for x in m.acl if x.user == removed][0] + ctx.current.delete(ma) + for p in people - old_people: + ma = MachineAccess(machine_id=m.machine_id, user=p) + ctx.current.save(ma) + def refreshCache(): transaction = ctx.current.create_transaction() try: machines = Machine.select() for m in machines: - people = set() - people.update(expandLocker(m.owner)) - people.update(expandName(m.administrator)) - print '%s: %s' % (m.name, ' '.join(people)) - old_people = set(a.user for a in m.acl) - for removed in old_people - people: - ma = [x for x in m.acl if x.user == removed][0] - ctx.current.delete(ma) - for p in people - old_people: - ma = MachineAccess(machine_id=m.machine_id, user=p) - ctx.current.save(ma) - ctx.current.flush() + refreshMachine(m) + ctx.current.flush() # Atomically execute our changes transaction.commit() -- 1.7.9.5