svn keywords
[plcapi.git] / PLC / Methods / AddAddressType.py
index 25f9d42..ae88e58 100644 (file)
@@ -1,8 +1,12 @@
+# $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 not in ['address_type_id']
 
 class AddAddressType(Method):
     """
@@ -14,20 +18,21 @@ class AddAddressType(Method):
 
     roles = ['admin']
 
-    can_update = lambda (field, value): field in ['description']
-    update_fields = dict(filter(can_update, AddressType.fields.items()))
+    address_type_fields = dict(filter(can_update, AddressType.fields.items()))
 
     accepts = [
-        PasswordAuth(),
-        AddressType.fields['name'],
-        update_fields
+        Auth(),
+        address_type_fields
         ]
 
     returns = Parameter(int, 'New address_type_id (> 0) if successful')
+        
 
-    def call(self, auth, name, address_type_fields = {}):
+    def call(self, auth, address_type_fields):
+        address_type_fields = dict(filter(can_update, address_type_fields.items()))
         address_type = AddressType(self.api, address_type_fields)
-        address_type['name'] = name
         address_type.sync()
 
-        return address_type['address_type_id']
+       self.event_objects = {'AddressType' : [address_type['address_type_id']]}
+        
+       return address_type['address_type_id']