[Zope3-checkins] CVS: Zope3/src/zope/app/component -
contentdirective.py:1.16 metaconfigure.py:1.28
Stephan Richter
srichter at cosmos.phy.tufts.edu
Mon Mar 8 07:07:05 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/component
In directory cvs.zope.org:/tmp/cvs-serv13053/src/zope/app/component
Modified Files:
contentdirective.py metaconfigure.py
Log Message:
Adjusted code to use the new APIs for permissions and principals. Also, use
the utility service instead of the permission registry to look up permissions.
=== Zope3/src/zope/app/component/contentdirective.py 1.15 => 1.16 ===
--- Zope3/src/zope/app/component/contentdirective.py:1.15 Fri Mar 5 17:08:58 2004
+++ Zope3/src/zope/app/component/contentdirective.py Mon Mar 8 07:05:54 2004
@@ -17,16 +17,16 @@
"""
from types import ModuleType
from zope.interface import classImplements
-from zope.component import getService
from zope.component.factory import FactoryInfo
from zope.app.services.servicenames import Factories
from zope.configuration.exceptions import ConfigurationError
from zope.app.component.classfactory import ClassFactory
from zope.app.security.protectclass \
import protectLikeUnto, protectName, protectSetAttribute
-from zope.app.security.registries.permissionregistry import permissionRegistry
from zope.app.component.interface import provideInterface
+from zope.app import zapi
from zope.security.checker import CheckerPublic
+from zope.app.security.permission import checkPermission
from zope.schema.interfaces import IField
@@ -42,13 +42,13 @@
pass
def handler(serviceName, methodName, *args, **kwargs):
- method=getattr(getService(None, serviceName), methodName)
+ method=getattr(zapi.getService(None, serviceName), methodName)
method(*args, **kwargs)
def assertPermission(permission=None, *args, **kw):
"""Check if permission is defined"""
if permission is not None:
- permissionRegistry.ensurePermissionDefined(permission)
+ checkPermission(None, permission)
class ContentDirective:
@@ -204,4 +204,4 @@
factory = ClassFactory(_class, title, description, permission)
info = FactoryInfo(title, description)
- getService(None, Factories).provideFactory(id, factory, info)
+ zapi.getService(None, Factories).provideFactory(id, factory, info)
=== Zope3/src/zope/app/component/metaconfigure.py 1.27 => 1.28 ===
--- Zope3/src/zope/app/component/metaconfigure.py:1.27 Fri Mar 5 10:53:17 2004
+++ Zope3/src/zope/app/component/metaconfigure.py Mon Mar 8 07:05:54 2004
@@ -15,19 +15,19 @@
$Id$
"""
-
+from zope.interface import Interface
+from zope.component.service import UndefinedService
from zope.configuration.exceptions import ConfigurationError
+from zope.security.checker import InterfaceChecker, CheckerPublic, \
+ Checker, NamesChecker
from zope.security.proxy import Proxy, ProxyFactory
-from zope.component import getService, getServiceManager
from zope.component.factory import FactoryInfo
-from zope.app.services.servicenames import Adapters
-from zope.app.services.servicenames import Factories, Presentation
+
+from zope.app import zapi
from zope.app.component.interface import queryInterface
-from zope.security.checker import InterfaceChecker, CheckerPublic, \
- Checker, NamesChecker
-from zope.app.security.registries.permissionregistry import permissionRegistry
-from zope.component.service import UndefinedService
-import zope.interface
+from zope.app.security.permission import checkPermission
+from zope.app.services.servicenames import Adapters, Factories, Presentation
+
PublicPermission = 'zope.Public'
@@ -35,14 +35,14 @@
# directly importing the various services) not only because it makes
# unit tests easier, but also because it reinforces that the services
# should always be obtained through the
-# IPlacefulComponentArchitecture interface methods
+# IPlacefulComponentArchitecture interface methods.
# But these services aren't placeful! And we need to get at things that
# normal service clients don't need! Jim
def handler(serviceName, methodName, *args, **kwargs):
- method=getattr(getService(None, serviceName), methodName)
+ method=getattr(zapi.getService(None, serviceName), methodName)
method(*args, **kwargs)
# We can't use the handler for serviceType, because serviceType needs
@@ -52,11 +52,11 @@
def checkingHandler(permission=None, *args, **kw):
"""Check if permission is defined"""
if permission is not None:
- permissionRegistry.ensurePermissionDefined(permission)
+ checkPermission(None, permission)
handler(*args, **kw)
def managerHandler(methodName, *args, **kwargs):
- method=getattr(getServiceManager(None), methodName)
+ method=getattr(zapi.getServiceManager(None), methodName)
method(*args, **kwargs)
def interface(_context, interface, type=None):
@@ -144,7 +144,7 @@
def provideFactory(name, factory, title, description, permission):
# make sure the permission is defined
if permission is not None:
- permissionRegistry.ensurePermissionDefined(permission)
+ checkPermission(None, permission)
if permission == PublicPermission:
permission = CheckerPublic
@@ -157,7 +157,7 @@
__call__=permission)
)
info = FactoryInfo(title, description)
- getService(None, Factories).provideFactory(name, factory, info)
+ zapi.getService(None, Factories).provideFactory(name, factory, info)
def _checker(_context, permission, allowed_interface, allowed_attributes):
if (not allowed_attributes) and (not allowed_interface):
@@ -181,7 +181,7 @@
def resource(_context, factory, type, name, layer='default',
permission=None,
allowed_interface=None, allowed_attributes=None,
- provides=zope.interface.Interface):
+ provides=Interface):
if ((allowed_attributes or allowed_interface)
and (not permission)):
@@ -219,7 +219,7 @@
def view(_context, factory, type, name, for_, layer='default',
permission=None, allowed_interface=None, allowed_attributes=None,
- provides=zope.interface.Interface):
+ provides=Interface):
if for_ == '*':
for_ = None
@@ -315,7 +315,7 @@
# We have to wait till execution time so we can find out the interface.
# Waaaa.
- service_manager = getServiceManager(None)
+ service_manager = zapi.getServiceManager(None)
if permission:
for stype, interface in service_manager.getServiceDefinitions():
More information about the Zope3-Checkins
mailing list