Add document rights registration to core
authorSverre Rabbelier <srabbelier@gmail.com>
Fri, 18 Sep 2009 19:55:03 +0200
changeset 2955 b799af27440e
parent 2954 9ea3b04d929c
child 2956 50ce8ac13932
Add document rights registration to core
app/soc/modules/core.py
--- a/app/soc/modules/core.py	Fri Sep 18 19:34:30 2009 +0200
+++ b/app/soc/modules/core.py	Fri Sep 18 19:55:03 2009 +0200
@@ -112,6 +112,7 @@
     self.sidebar = []
     self.per_request_cache = {}
     self.in_request = False
+    self.rights = {}
 
   ##
   ## internal
@@ -205,6 +206,15 @@
 
     return sorted(sidebar, key=lambda x: x.get('group'))
 
+  def getRightsChecker(self, prefix):
+    """Returns a rights checker for this site.
+    """
+
+    from soc.logic import rights as rights_logic
+
+    self.callService('registerRights', True)
+    return rights_logic.Checker(self.rights, prefix)
+
   ###
   ### Core control code
   ###
@@ -312,3 +322,9 @@
     """
 
     self.sidebar.append(entry)
+
+  def registerRight(self, key, value):
+    """Registers the specified right.
+    """
+
+    self.rights[key] = value