[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture - ContextDependent.py:1.1.2.1 metaConfigure.py:1.1.2.7
Jim Fulton
jim@zope.com
Thu, 3 Jan 2002 14:29:55 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv16747/ComponentArchitecture
Modified Files:
Tag: Zope-3x-branch
metaConfigure.py
Added Files:
Tag: Zope-3x-branch
ContextDependent.py
Log Message:
Refactored configuration framework:
- Configuration directives must be written to a
a different framework. See
ConfigurationDirectiveInterfaces.
- Configuration directives now don't take actions immediately.
Instead, they return a sequence of discriminators and callables
objects with arguments. This allows configuration to be defered to
allow overriding and conflct detection.
- Can now detect conflicting directives
- Can override directives. Directives in including configuration files
override directives in included files. Conflicting directives are
decided based on discriminators.
- Added new directives for defining directives. All directives, except
for a few bootstrap irectives, are now configurable in the
configuration file. This makes directives a little more discoverable
and facilitates extension of directives.
=== Added File Zope3/lib/python/Zope/ComponentArchitecture/ContextDependent.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""
Revision information: $Id: ContextDependent.py,v 1.1.2.1 2002/01/03 19:29:24 jim Exp $
"""
class ContextDependent:
""" standard boilerplate for context dependent objects"""
def __init__(self, context):
self.__context = context
def getContext(self):
return self.__context
=== Zope3/lib/python/Zope/ComponentArchitecture/metaConfigure.py 1.1.2.6 => 1.1.2.7 ===
from hooks import provideAdapter, provideUtility, provideView
-from Zope.Configuration.meta import register
from Zope.Configuration.name import resolve
from Zope.Configuration import namespace
+from Service import defineService, provideService
-def provideAdapterDir(component, provides, for_=None):
+def adapter(component, provides, for_=None):
if for_ is not None: for_ = resolve(for_)
- provideAdapter(for_, resolve(provides), resolve(component))
+ provides = resolve(provides)
+ return [(
+ ('adapter', for_, provides),
+ provideAdapter, (for_, provides, resolve(component))
+ )]
-def provideUtilityDir(component, provides):
- provideUtility(resolve(provides), resolve(component))
+def utility(component, provides):
+ provides = resolve(provides)
+ component = resolve(component)
+ return [(
+ ('utility', provides),
+ provideUtility,(provides, component)
+ )]
-def provideViewDir(component, type, name, for_=None):
+def view(component, type, name, for_=None):
if for_ is not None: for_ = resolve(for_)
- provideView(for_, name, resolve(type), resolve(component))
+ type = resolve(type)
+ component = resolve(component)
+ return [(
+ ('view', for_, name, type),
+ provideView, (for_, name, type, component)
+ )]
-def provideDefaultViewDir(component, type, name, for_=None):
+def defaultView(component, type, name, for_=None):
if for_ is not None: for_ = resolve(for_)
- provideView(for_, name, resolve(type), resolve(component))
- provideView(for_, "", resolve(type), resolve(component))
-
-def metaConfigure():
- register(namespace('zope'), 'adapter', provideAdapterDir)
- register(namespace('zope'), 'utility', provideUtilityDir)
- register(namespace('zope'), 'presention', provideViewDir)
- register(namespace('zope'), 'defaultView',
- provideDefaultViewDir)
+ type = resolve(type)
+ component = resolve(component)
+ return [
+ (('view', for_, name, type),
+ provideView, (for_, name, type, component)),
+ (('view', for_, '', type),
+ provideView, (for_, '', type, component)),
+ ]
+
+def serviceType(name, interface):
+ return [(
+ ('serviceType', name),
+ defineService, (name, resolve(interface))
+ )]
+
+def service(name, component):
+ component = resolve(component)
+ return [(
+ ('service', name),
+ provideService, (name, component)
+ )]