- fix typo
[plcapi.git] / PLC / Methods / AddAddressTypeToAddress.py
index 64f532a..b4cf700 100644 (file)
@@ -3,7 +3,7 @@ from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
 from PLC.AddressTypes import AddressType, AddressTypes
 from PLC.Addresses import Address, Addresses
 from PLC.Parameter import Parameter, Mixed
 from PLC.AddressTypes import AddressType, AddressTypes
 from PLC.Addresses import Address, Addresses
-from PLC.Auth import PasswordAuth
+from PLC.Auth import Auth
 
 class AddAddressTypeToAddress(Method):
     """
 
 class AddAddressTypeToAddress(Method):
     """
@@ -17,7 +17,7 @@ class AddAddressTypeToAddress(Method):
     roles = ['admin', 'pi']
 
     accepts = [
     roles = ['admin', 'pi']
 
     accepts = [
-        PasswordAuth(),
+        Auth(),
         Mixed(AddressType.fields['address_type_id'],
               AddressType.fields['name']),
         Address.fields['address_id']
         Mixed(AddressType.fields['address_type_id'],
               AddressType.fields['name']),
         Address.fields['address_id']
@@ -25,13 +25,14 @@ class AddAddressTypeToAddress(Method):
 
     returns = Parameter(int, '1 if successful')
 
 
     returns = Parameter(int, '1 if successful')
 
+
     def call(self, auth, address_type_id_or_name, address_id):
     def call(self, auth, address_type_id_or_name, address_id):
-        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]
 
         if not address_types:
             raise PLCInvalidArgument, "No such address type"
         address_type = address_types[0]
 
-        addresses = Addresses(self.api, [address_id]).values()
+        addresses = Addresses(self.api, [address_id])
         if not addresses:
             raise PLCInvalidArgument, "No such address"
         address = addresses[0]
         if not addresses:
             raise PLCInvalidArgument, "No such address"
         address = addresses[0]
@@ -41,5 +42,6 @@ class AddAddressTypeToAddress(Method):
                 raise PLCPermissionDenied, "Address must be associated with one of your sites"
 
         address.add_address_type(address_type)
                 raise PLCPermissionDenied, "Address must be associated with one of your sites"
 
         address.add_address_type(address_type)
+       self.object_ids = [address['address_id']]
 
         return 1
 
         return 1