svn keywords
[plcapi.git] / PLC / Methods / UpdateAddressType.py
index 950c311..6110de2 100644 (file)
@@ -1,8 +1,10 @@
+# $Id$
+# $URL$
 from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
 from PLC.AddressTypes import AddressType, AddressTypes
-from PLC.Auth import PasswordAuth
+from PLC.Auth import Auth
 
 can_update = lambda (field, value): field in ['name', 'description']
 
@@ -16,13 +18,13 @@ class UpdateAddressType(Method):
 
     roles = ['admin']
 
-    update_fields = dict(filter(can_update, AddressType.fields.items()))
+    address_type_fields = dict(filter(can_update, AddressType.fields.items()))
 
     accepts = [
-        PasswordAuth(),
+        Auth(),
         Mixed(AddressType.fields['address_type_id'],
               AddressType.fields['name']),
-        update_fields
+        address_type_fields
         ]
 
     returns = Parameter(int, '1 if successful')
@@ -30,12 +32,13 @@ class UpdateAddressType(Method):
     def call(self, auth, address_type_id_or_name, address_type_fields):
         address_type_fields = dict(filter(can_update, address_type_fields.items()))
 
-        address_types = AddressTypes(self.api, [address_type_id_or_name]).values()
+        address_types = AddressTypes(self.api, [address_type_id_or_name])
         if not address_types:
             raise PLCInvalidArgument, "No such address type"
         address_type = address_types[0]
 
         address_type.update(address_type_fields)
         address_type.sync()
+       self.event_objects = {'AddressType': [address_type['address_type_id']]}
 
         return 1