[Zope-Checkins] CVS: Zope3/lib/python/Zope/Configuration - metametaConfigure.py:1.1.2.1

R. David Murray bitz@bitdance.com
Mon, 14 Oct 2002 18:53:55 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Configuration
In directory cvs.zope.org:/tmp/cvs-serv7353

Added Files:
      Tag: rdmurray-metameta-branch
	metametaConfigure.py 
Log Message:
This file defines versions of the metaconfiguration directives that
allow for the augmented syntax in my ZCMLHelpViaMetaConfiguration
proposal.  They don't *do* anything with the additional info, though,
so this is the file to use for normal z3 execution.


=== Added File Zope3/lib/python/Zope/Configuration/metametaConfigure.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.
# 
##############################################################################
"""
$Id: metametaConfigure.py,v 1.1.2.1 2002/10/14 22:53:54 rdmurray Exp $
"""
from meta import DirectiveNamespace as bootstrapDirectiveNamespace
from meta import Subdirective as bootstrapSubdirective
from meta import _registerDirective
from INonEmptyDirective import INonEmptyDirective
from IEmptyDirective import IEmptyDirective
from ISubdirectiveHandler import ISubdirectiveHandler

#
# Meta-meta configuration.  These routines replace the bootstrap ones
# defined in meta.py.
#

class DirectiveNamespace(bootstrapDirectiveNamespace):

    __class_implements_ = INonEmptyDirective
    __implements__ = ISubdirectiveHandler

    def _useDescription(self, namespace, name, description, subs): pass

    def directive(self, _context, name, handler, attributes='',
            namespace=None, description=''):
        subs, namespace = self._register(_context, name, handler, namespace)
        self._useDescription(namespace, name, description, subs)
        return Subdirective(subs, namespace=namespace, name=name)
    directive.__implements__ = INonEmptyDirective


def Directive(_cotnext, namespace, name, handler, description='',
        attributes=''):
    subs, namespace = _registerDirective(_context, namespace, name, handler)
    return Subdirective(subs, namespace=namespace, name=name)

Directive.__implements__ = INonEmptyDirective


class Subdirective(bootstrapSubdirective):
    """An extended Subdirective that handles descriptions and attributes"""

    __implements__ = ISubdirectiveHandler

    def __init__(self, subs, namespace=None, name=None):
        bootstrapSubdirective.__init__(self,subs,namespace)
        self._name = name

    def _useDescription(self, namespace, name, subs, description): pass

    def subdirective(self, _context, name, attributes='',
                     namespace=None, handler_method=None, description=''):
        subs, namespace = self._register(_context, name, namespace,
                                         handler_method)
        self._useDescription(namespace, name, subs, description)
        return Subdirective(subs, namespace=namespace, name=name)
    subdirective.__implements__ = INonEmptyDirective

    def _useAttributeDescription(self, name, required, description): pass

    def attribute(self, _context, name, required=None, description=''):
        self._useAttributeDescription(name, required, description)
        return ()
    attribute.__implements__ = IEmptyDirective