[Zope3-checkins] CVS: Zope3/src/zope/component/tests - components.py:1.1.2.1 factory.py:1.1.2.1 views.py:1.1.2.1

Jim Fulton jim@zope.com
Mon, 23 Dec 2002 15:20:05 -0500


Update of /cvs-repository/Zope3/src/zope/component/tests
In directory cvs.zope.org:/tmp/cvs-serv739

Added Files:
      Tag: NameGeddon-branch
	components.py factory.py views.py 
Log Message:
Got tests passing

=== Added File Zope3/src/zope/component/tests/components.py ===
##############################################################################
#
# Copyright (c) 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: components.py,v 1.1.2.1 2002/12/23 20:20:04 jim Exp $
"""
__metaclass__ = type # All classes are new style when run with Python 2.2+

from zope.interface import Interface
from zope.interface import Attribute

class IApp(Interface):
    a = Attribute('test attribute')
    def f(): "test func"

class IContent(Interface): pass

class Content: __implements__ = IContent

class Comp:
    __used_for__ = IContent
    __implements__ = IApp

    a=1
    def f(): pass

comp = Comp()



=== Added File Zope3/src/zope/component/tests/factory.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: factory.py,v 1.1.2.1 2002/12/23 20:20:04 jim Exp $
"""
from zope.component.interfaces import IFactory
from zope.interface import Interface

class IX(Interface):
    """the dummy interface which class X supposedly implements,
    according to the factory"""

class X:
    __implements__=IX
    def __init__(self, *args, **kwargs):
        self.args=args
        self.kwargs=kwargs


class ClassFactoryWrapper:
    __implements__ = IFactory
    def __init__(self, klass):
        self.__klass=klass
    def __call__(self, *args, **kwargs):
        return self.__klass(*args, **kwargs)
    def getInterfaces(self):
        return getattr(self.__klass,'__implements__', None)

f=ClassFactoryWrapper(X)

=== Added File Zope3/src/zope/component/tests/views.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.
# 
##############################################################################
"""

Revision information: $Id: views.py,v 1.1.2.1 2002/12/23 20:20:04 jim Exp $
"""

from zope.interface import Interface


class IV(Interface):
    def index(): pass
    
class IC(Interface): pass

class V1:
    __implements__ = IV

    def __init__(self,context, request): 
        self.context = context
        self.request = request

    def index(self): return 'V1 here'

    def action(self): return 'done'

class VZMI(V1):
    def index(self): return 'ZMI here'

class R1:

    def index(self): return 'R1 here'

    def action(self): return 'R done'

    def __init__(self, request): 
        pass 

    __implements__ = IV

class RZMI(R1):
    pass