added sfa upcalls
[plcapi.git] / PLC / Methods / DeletePerson.py
index 93ae858..738850c 100644 (file)
@@ -1,8 +1,11 @@
+# $Id$
+# $URL$
 from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
 from PLC.Persons import Person, Persons
 from PLC.Auth import Auth
+from PLC.SFA import SFA
 
 class DeletePerson(Method):
     """
@@ -25,15 +28,15 @@ class DeletePerson(Method):
 
     returns = Parameter(int, '1 if successful')
 
-
     def call(self, auth, person_id_or_email):
         # Get account information
         persons = Persons(self.api, [person_id_or_email])
         if not persons:
             raise PLCInvalidArgument, "No such account"
-
         person = persons[0]
-       PLCCheckLocalPerson(person,"DeletePerson")
+
+        if person['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local account"
 
         # Authenticated function
         assert self.caller is not None
@@ -44,8 +47,11 @@ class DeletePerson(Method):
 
         person.delete()
        
-       # Logging variables
-       self.object_ids = [person['person_id']]
-       self.message = 'Person %d deleted' % person['person_id']
+        # Logging variables
+        self.event_objects = {'Person': [person['person_id']]}
+        self.message = 'Person %d deleted' % person['person_id']
+
+        sfa = SFA()
+        sfa.delete_record(person, 'person')
 
         return 1