[z3-checkins] r5285 - z3/Five/trunk
philikon at codespeak.net
philikon at codespeak.net
Fri Jun 25 13:34:58 MEST 2004
Author: philikon
Date: Fri Jun 25 13:34:58 2004
New Revision: 5285
Modified:
z3/Five/trunk/meta.zcml
z3/Five/trunk/metaconfigure.py
Log:
Since it's ok now to depend on specific zope.app packages and we
already were depending on zope.app.component for the directive schemas,
we can just as well use the directive handlers from there, too (except
for the content directive handler). We were using mostly verbatim
copies, anyway.
Modified: z3/Five/trunk/meta.zcml
==============================================================================
--- z3/Five/trunk/meta.zcml (original)
+++ z3/Five/trunk/meta.zcml Fri Jun 25 13:34:58 2004
@@ -7,36 +7,36 @@
<meta:directive
name="permission"
schema="zope.app.security.metadirectives.IDefinePermissionDirective"
- handler=".metaconfigure.definePermission" />
+ handler="zope.app.security.metaconfigure.definePermission" />
<meta:directive
name="interface"
schema="zope.app.component.metadirectives.IInterfaceDirective"
- handler=".metaconfigure.interface"
+ handler="zope.app.component.metaconfigure.interface"
/>
<meta:directive
name="adapter"
schema="zope.app.component.metadirectives.IAdapterDirective"
- handler=".metaconfigure.adapter"
+ handler="zope.app.component.metaconfigure.adapter"
/>
<meta:directive
name="utility"
schema="zope.app.component.metadirectives.IUtilityDirective"
- handler=".metaconfigure.utility"
+ handler="zope.app.component.metaconfigure.utility"
/>
<meta:directive
name="serviceType"
schema="zope.app.component.metadirectives.IServiceTypeDirective"
- handler=".metaconfigure.serviceType"
+ handler="zope.app.component.metaconfigure.serviceType"
/>
<meta:directive
name="service"
schema="zope.app.component.metadirectives.IServiceDirective"
- handler=".metaconfigure.service"
+ handler="zope.app.component.metaconfigure.service"
/>
<meta:complexDirective
@@ -83,7 +83,7 @@
</meta:directives>
<meta:directives namespace="http://namespaces.zope.org/browser">
-
+
<meta:directive
name="page"
schema="zope.app.publisher.browser.metadirectives.IPageDirective"
Modified: z3/Five/trunk/metaconfigure.py
==============================================================================
--- z3/Five/trunk/metaconfigure.py (original)
+++ z3/Five/trunk/metaconfigure.py Fri Jun 25 13:34:58 2004
@@ -28,117 +28,7 @@
from security import CheckerPublic, CheckerPrivate
from security import protectName, initializeClass
-def handler(serviceName, methodName, *args, **kwargs):
- method=getattr(getService(serviceName), methodName)
- method(*args, **kwargs)
-
-def managerHandler(methodName, *args, **kwargs):
- method=getattr(getServices(), methodName)
- method(*args, **kwargs)
-
-def serviceType(_context, id, interface):
- _context.action(
- discriminator = ('serviceType', id),
- callable = managerHandler,
- args = ('defineService', id, interface),
- )
-
- if interface.__name__ not in ['IUtilityService']:
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = (interface.__module__+'.'+interface.getName(),
- interface)
- )
-
-def provideService(serviceType, component, permission):
- # XXX this can probably be eliminated and provideService can be used
- # directly
- service_manager = getServices()
- service_manager.provideService(serviceType, component)
-
-def service(_context, serviceType, component=None, permission=None,
- factory=None):
- if factory:
- if component:
- raise TypeError("Can't specify factory and component.")
-
- component = factory()
-
- _context.action(
- discriminator = ('service', serviceType),
- callable = provideService,
- args = (serviceType, component, permission),
- )
-
-def interface(_context, interface, type=None):
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = ('', interface, type)
- )
-
-def adapter(_context, factory, provides, for_, permission=None, name=''):
- for_ = tuple(for_)
-
- # Generate a single factory from multiple factories:
- factories = factory
- if len(factories) == 1:
- factory = factories[0]
- elif len(factories) < 1:
- raise ValueError("No factory specified")
- elif len(factories) > 1 and len(for_) != 1:
- raise ValueError("Can't use multiple factories and multiple for")
- else:
- def factory(ob):
- for f in factories:
- ob = f(ob)
- return ob
- # Store the original factory for documentation
- factory.factory = factories[0]
-
- _context.action(
- discriminator = ('adapter', for_, provides, name),
- callable = handler,
- args = (Adapters, 'register',
- for_, provides, name, factory, _context.info),
- )
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = ('', provides)
- )
- if for_:
- for iface in for_:
- if iface is not None:
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = ('', iface)
- )
-
-def utility(_context, provides, component=None, factory=None,
- permission=None, name=''):
- if factory:
- if component:
- raise TypeError("Can't specify factory and component.")
- component = factory()
-
- _context.action(
- discriminator = ('utility', provides, name),
- callable = handler,
- args = ('Utilities', 'provideUtility',
- provides, component, name),
- )
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = (provides.__module__ + '.' + provides.getName(), provides)
- )
-
-def definePermission(_context, id, title, description=''):
- permission = Permission(id, title, description)
- utility(_context, IPermission, permission, name=id)
+from zope.app.component.metaconfigure import handler, managerHandler
class ContentDirective:
More information about the z3-checkins
mailing list