[Zope3-checkins] CVS: Zope3/src/zope/app/component - decoratorservice.py:1.1.2.2 hooks.py:1.5.8.2

Marius Gedminas mgedmin@codeworks.lt
Wed, 14 May 2003 06:39:35 -0400


Update of /cvs-repository/Zope3/src/zope/app/component
In directory cvs.zope.org:/tmp/cvs-serv2024/src/zope/app/component

Modified Files:
      Tag: stevea-decorators-branch
	decoratorservice.py hooks.py 
Log Message:
Refactored WATCH_CHECKERS from base Checker code into a separate mixin class.
New class: DecoratedChecker.
Some work on the global decorator service.



=== Zope3/src/zope/app/component/decoratorservice.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/component/decoratorservice.py:1.1.2.1	Wed May 14 03:36:08 2003
+++ Zope3/src/zope/app/component/decoratorservice.py	Wed May 14 06:39:04 2003
@@ -21,3 +21,6 @@
 
 queryDecoratorSpec = _reg.get
 
+from zope.testing.cleanup import addCleanUp
+addCleanUp(_reg.clear)
+del addCleanUp


=== Zope3/src/zope/app/component/hooks.py 1.5.8.1 => 1.5.8.2 ===
--- Zope3/src/zope/app/component/hooks.py:1.5.8.1	Wed May 14 03:36:08 2003
+++ Zope3/src/zope/app/component/hooks.py	Wed May 14 06:39:04 2003
@@ -26,7 +26,7 @@
 from zope.app.component.decoratorservice import queryDecoratorSpec
 from zope.security.proxy import Proxy, getChecker, getObject
 from zope.proxy.context.decorator import Decorator
-from zope.security.checker import selectChecker, BasicTypes
+from zope.security.checker import DecoratedChecker
 
 def getServiceManager_hook(context, local=False):
     """Get a service manager based on context.
@@ -88,6 +88,28 @@
     return _ob
 
 def decorate(spec, ob, parent, kw):
+    if type(ob) is Proxy:
+        checker = getChecker(ob)
+        unproxied_ob = getObject(ob)
+    else:
+        checker = None
+        unproxied_ob = ob
+    if spec.mixinIsTrusted:
+        inner = None
+    else:
+        inner = ob
+    d = Decorator(unproxied_ob, parent, spec.mixinFactory, spec.names, {},
+                  inner, **kw)
+    if checker is not None:
+        if spec.permissionMap or spec.setPermissionMap:
+            checker = DecoratedChecker(checker, spec.permissionMap,
+                                       spec.setPermissionMap)
+        d = Proxy(d, checker)
+    return d
+
+
+
+def XXXdecorate(spec, ob, parent, kw):
     """
     """
     if t is Proxy: