Zope Subversion Repository

  Zope

Zope: zope.security/trunk/src/zope/security/tests/adapter.py

File: [Zope] / zope.security / trunk / src / zope / security / tests / adapter.py (download) (as text)
Revision: 125980, Thu May 17 21:22:20 2012 UTC (13 months ago) by tseaver
File size: 1505 byte(s)
Drop support for Python 2.4 and 2.5.

Replace deprecated 'zope.component.adapts' usage with equivalent
'zope.component.adapter' decorator.

Replace deprecated 'zope.interface.classProvides' usage with equivalent
'zope.interface.provider' decorator.

Replace deprecated 'zope.interface.implements' usage with equivalent
'zope.interface.implementer' decorator.

##############################################################################
#
# Copyright (c) 2004 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""Sample adapter class for testing
"""
import zope.interface
import zope.component
import components

class I1(zope.interface.Interface):
    pass

class I2(zope.interface.Interface):
    pass

class I3(zope.interface.Interface):
    def f1(): pass
    def f2(): pass
    def f3(): pass

class IS(zope.interface.Interface):
    pass


class Adapter(object):
    def __init__(self, *args):
        self.context = args

@zope.interface.implementer(I1)
class A1(Adapter):
    pass

@zope.interface.implementer(I2)
class A2(Adapter):
    pass

@zope.component.adapter(components.IContent, I1, I2)
@zope.interface.implementer(I3)
class A3(Adapter):
    pass

class A4:
    pass

a4 = A4()

@zope.interface.implementer(I1, I2)
class A5:
    pass

a5 = A5()

def Handler(content, *args):
    # uninteresting handler
    content.args = getattr(content, 'args', ()) + (args, )

webmaster@zope.org

Powered by ViewCVS 1.0-dev
(Powered by Apache)

ViewCVS and CVS Help