[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ClassDirective - __init__.py:1.1.2.1 class-meta.zcml:1.1.2.1 metaConfigure.py:1.1.2.1
Steve Alexander
steve@cat-box.net
Wed, 29 May 2002 13:19:29 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/ClassDirective
In directory cvs.zope.org:/tmp/cvs-serv14383/lib/python/Zope/App/ClassDirective
Added Files:
Tag: Zope3InWonderland-branch
__init__.py class-meta.zcml metaConfigure.py
Log Message:
Added first small part of the new "class" directive.
=== Added File Zope3/lib/python/Zope/App/ClassDirective/__init__.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 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.
#
##############################################################################
"""
'class' configuration directive.
"""
=== Added File Zope3/lib/python/Zope/App/ClassDirective/class-meta.zcml ===
<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
<!-- Zope.App.ClassDirective -->
<directives namespace="http://namespaces.zope.org/zope">
<directive name="class"
attributes="class"
handler="Zope.App.ClassDirective.metaConfigure.classDirective" >
<subdirective name="implements"
attributes="interface" />
</directive>
</directives>
</zopeConfigure>
=== Added File Zope3/lib/python/Zope/App/ClassDirective/metaConfigure.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 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.
#
##############################################################################
""" Register class directive.
$Id: metaConfigure.py,v 1.1.2.1 2002/05/29 17:19:28 stevea Exp $
"""
from Zope.Configuration.ConfigurationDirectiveInterfaces \
import INonEmptyDirective
from Zope.Configuration.Action import Action
import Interface
class classDirective:
__implements__ = INonEmptyDirective
def __init__(self, _context, class_):
self.__class = _context.resolve(class_)
# not used yet
#self.__name = class_
#self.__context = _context
def implements(self, _context, interface):
resolved_interface = _context.resolve(interface)
return [
Action(
discriminator = ('configureClass', self.__class, object()),
callable = Interface.Implements.implements,
# the last argument is check=1, which causes implements
# to verify that the class does implement the interface
args = (self.__class, resolved_interface, 1),
)
]
def __call__(self):
"Handle empty/simple declaration."
return ()