[Zope3-checkins] CVS: Zope3/src/zope/app/component -
metaconfigure.py:1.19
Jim Fulton
jim at zope.com
Sun Sep 21 13:31:55 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/component
In directory cvs.zope.org:/tmp/cvs-serv13112/src/zope/app/component
Modified Files:
metaconfigure.py
Log Message:
Changed the way permissions are handled. Now just create a checker to
be used later when the component is proxied. Don't proxy the component
right away.
=== Zope3/src/zope/app/component/metaconfigure.py 1.18 => 1.19 ===
--- Zope3/src/zope/app/component/metaconfigure.py:1.18 Fri Aug 15 20:43:18 2003
+++ Zope3/src/zope/app/component/metaconfigure.py Sun Sep 21 13:31:24 2003
@@ -63,12 +63,28 @@
args = (Interfaces, 'provideInterface', '', interface)
)
+def proxify(ob, checker):
+ """Try to get the object proxied with the checker, but not too soon
+
+ We really don't want to proxy the object unless we need to.
+ """
+
+ try:
+ ob.__Security_checker__ = checker
+ except AttributeError:
+ ob = Proxy(ob, checker)
+
+ return ob
+
+
def adapter(_context, factory, provides, for_, permission=None, name=''):
if permission is not None:
if permission == PublicPermission:
permission = CheckerPublic
checker = InterfaceChecker(provides, permission)
- factory.append(lambda c: Proxy(c, checker))
+ factory.append(lambda c: proxify(c, checker))
+
+
_context.action(
discriminator = ('adapter', for_, provides, name),
callable = checkingHandler,
@@ -99,7 +115,7 @@
permission = CheckerPublic
checker = InterfaceChecker(provides, permission)
- component = Proxy(component, checker)
+ component = proxify(component, checker)
_context.action(
discriminator = ('utility', provides, name),
@@ -174,7 +190,7 @@
allowed_interface, allowed_attributes)
def proxyResource(request, factory=factory, checker=checker):
- return Proxy(factory(request), checker)
+ return proxify(factory(request), checker)
factory = proxyResource
@@ -213,7 +229,7 @@
allowed_interface, allowed_attributes)
def proxyView(context, request, factory=factory[-1], checker=checker):
- return Proxy(factory(context, request), checker)
+ return proxify(factory(context, request), checker)
factory[-1] = proxyView
@@ -302,7 +318,7 @@
try:
component.__Security_checker__ = checker
except: # too bad exceptions aren't more predictable
- component = Proxy(component, checker)
+ component = proxify(component, checker)
service_manager.provideService(serviceType, component)
More information about the Zope3-Checkins
mailing list