factor out the privilege processing code
diff --git a/xos/tosca/resources/xosresource.py b/xos/tosca/resources/xosresource.py
index ef59485..fa0f7d9 100644
--- a/xos/tosca/resources/xosresource.py
+++ b/xos/tosca/resources/xosresource.py
@@ -85,6 +85,16 @@
     def can_delete(self, obj):
         return True
 
+    def postprocess_privileges(self, roleclass, privclass, rolemap):
+        for (rel, role) in rolemap:
+            for email in self.get_requirements(rel):
+                role = self.get_xos_object(roleclass, role=role)
+                user = self.get_xos_object(User, email=email)
+                if not privclass.objects.filter(user=user, role=role, slice=obj):
+                    sp = privclass(user=user, role=role, slice=obj)
+                    sp.save()
+                    self.info("Added privilege on %s role %s for %s" % (str(obj), str(role), str(user)))
+
     def postprocess(self, obj):
         pass