exceptions thrown by AddPersonToSlice and DeletePersonFromSlice show more context
[plcapi.git] / PLC / Methods / AddPersonToSlice.py
index 4dcae35..41e6a6a 100644 (file)
@@ -1,4 +1,3 @@
-# $Id#
 from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
@@ -9,7 +8,7 @@ from PLC.Auth import Auth
 class AddPersonToSlice(Method):
     """
     Adds the specified person to the specified slice. If the person is
-    already a member of the slice, no errors are returned. 
+    already a member of the slice, no errors are returned.
 
     Returns 1 if successful, faults otherwise.
     """
@@ -30,13 +29,13 @@ class AddPersonToSlice(Method):
         # Get account information
         persons = Persons(self.api, [person_id_or_email])
         if not persons:
-            raise PLCInvalidArgument, "No such account"
+            raise PLCInvalidArgument, "No such account %s"%person_id_or_email
         person = persons[0]
 
         # Get slice information
         slices = Slices(self.api, [slice_id_or_name])
         if not slices:
-            raise PLCInvalidArgument, "No such slice"
+            raise PLCInvalidArgument, "No such slice %s"%slice_id_or_name
         slice = slices[0]
 
         # N.B. Allow foreign users to be added to local slices and
@@ -47,16 +46,16 @@ class AddPersonToSlice(Method):
 
         # If we are not admin, make sure the caller is a PI
         # of the site associated with the slice
-       if 'admin' not in self.caller['roles']:
+        if 'admin' not in self.caller['roles']:
             if slice['site_id'] not in self.caller['site_ids']:
-                raise PLCPermissionDenied, "Not allowed to add users to this slice"
+                raise PLCPermissionDenied, "Not allowed to add users to slice %s"%slice_id_or_name
 
-       if slice['slice_id'] not in person['slice_ids']:
+        if slice['slice_id'] not in person['slice_ids']:
             slice.add_person(person)
 
         # Logging variables
-       self.event_objects = {'Person': [person['person_id']],
-                             'Slice': [slice['slice_id']]}     
-       self.object_ids = [slice['slice_id']]
+        self.event_objects = {'Person': [person['person_id']],
+                              'Slice': [slice['slice_id']]}
+        self.object_ids = [slice['slice_id']]
 
         return 1