Update cache for machines on their modification.
authorEric Price <ecprice@mit.edu>
Tue, 22 Apr 2008 04:03:45 +0000 (00:03 -0400)
committerEric Price <ecprice@mit.edu>
Tue, 22 Apr 2008 04:03:45 +0000 (00:03 -0400)
svn path=/trunk/packages/sipb-xen-www/; revision=446

code/main.py

index 3fe04d5..de28a63 100755 (executable)
@@ -39,6 +39,7 @@ from Cheetah.Template import Template
 import sipb_xen_database
 from sipb_xen_database import Machine, CDROM, ctx, connect, MachineAccess, Type, Autoinstall
 import validation
+import cache_acls
 from webcommon import InvalidInput, CodeError, g
 import controls
 
@@ -394,16 +395,21 @@ def modifyDict(user, fields):
                 disk.size = disksize
                 ctx.current.save(disk)
 
-        if owner is not None:
+        update_acl = False
+        if owner is not None and owner != machine.owner:
             machine.owner = owner
+            update_acl = True
         if name is not None:
             machine.name = name
-        if admin is not None:
+        if admin is not None and admin != machine.administrator:
             machine.administrator = admin
+            update_acl = True
         if contact is not None:
             machine.contact = contact
 
         ctx.current.save(machine)
+        if update_acl:
+            cache_acls.refreshMachine(machine)
         transaction.commit()
     except:
         transaction.rollback()