advisory_testing.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ##############################################################################
  2. #
  3. # Copyright (c) 2003 Zope Foundation and Contributors.
  4. # All Rights Reserved.
  5. #
  6. # This software is subject to the provisions of the Zope Public License,
  7. # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
  8. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
  9. # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10. # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
  11. # FOR A PARTICULAR PURPOSE.
  12. #
  13. ##############################################################################
  14. import sys
  15. from zope.interface.advice import addClassAdvisor
  16. from zope.interface.advice import getFrameInfo
  17. my_globals = globals()
  18. def ping(log, value):
  19. def pong(klass):
  20. log.append((value,klass))
  21. return [klass]
  22. addClassAdvisor(pong)
  23. try:
  24. from types import ClassType
  25. class ClassicClass:
  26. __metaclass__ = ClassType
  27. classLevelFrameInfo = getFrameInfo(sys._getframe())
  28. except ImportError:
  29. ClassicClass = None
  30. class NewStyleClass:
  31. __metaclass__ = type
  32. classLevelFrameInfo = getFrameInfo(sys._getframe())
  33. moduleLevelFrameInfo = getFrameInfo(sys._getframe())