def setUp(self):
        Zope2.startup_wsgi()
        transaction.begin()
        self.app = makerequest(Zope2.app())
        try:
            if not hasattr(self.app, 'error_log'):
                # If ZopeLite was imported, we have no default error_log
                from Products.SiteErrorLog.SiteErrorLog import SiteErrorLog
                self.app._setObject('error_log', SiteErrorLog())
            self.app.manage_addDTMLMethod('doc', '')

            self.logger = logging.getLogger('Zope.SiteErrorLog')
            self.log = logging.handlers.BufferingHandler(sys.maxsize)
            self.logger.addHandler(self.log)
            self.old_level = self.logger.level
            self.logger.setLevel(logging.ERROR)
        except Exception:
            self.tearDown()
Exemple #2
0
    def setUpApp(self):
        """Trigger Zope startup and set up the application.
        """

        # If the Testing module has been imported, the testinghome
        # variable is set and changes the way Zope2.startup() works.
        # We want the standard behavior so we remove it.

        import App.config
        config = App.config.getConfiguration()
        try:
            self._testingHome = config.testinghome
        except AttributeError:
            pass
        else:
            del config.testinghome
            App.config.setConfiguration(config)

        # Clean up after ZopeLite layer
        import ZPublisher.WSGIPublisher
        ZPublisher.WSGIPublisher._MODULES.clear()
        self._publisher_globals = {
            'load_app': ZPublisher.WSGIPublisher.load_app
        }
        if hasattr(ZPublisher.WSGIPublisher, '__old_load_app__'):
            old_load_app = ZPublisher.WSGIPublisher.__old_load_app__
            ZPublisher.WSGIPublisher.load_app = old_load_app
            self._publisher_globals['__old_load_app__'] = old_load_app
            del ZPublisher.WSGIPublisher.__old_load_app__

        # This uses the DB from the dbtab, as configured in setUpDatabase().
        # That DB then gets stored as Zope2.DB and becomes the default.

        import Zope2
        Zope2._began_startup = 0
        Zope2.startup_wsgi()
Exemple #3
0
    def setUpApp(self):
        """Trigger Zope startup and set up the application.
        """

        # If the Testing module has been imported, the testinghome
        # variable is set and changes the way Zope2.startup() works.
        # We want the standard behavior so we remove it.

        import App.config
        config = App.config.getConfiguration()
        try:
            self._testingHome = config.testinghome
        except AttributeError:
            pass
        else:
            del config.testinghome
            App.config.setConfiguration(config)

        # Clean up after ZopeLite layer
        import ZPublisher.WSGIPublisher
        ZPublisher.WSGIPublisher._MODULES.clear()
        self._publisher_globals = {
            'load_app': ZPublisher.WSGIPublisher.load_app
        }
        if hasattr(ZPublisher.WSGIPublisher, '__old_load_app__'):
            old_load_app = ZPublisher.WSGIPublisher.__old_load_app__
            ZPublisher.WSGIPublisher.load_app = old_load_app
            self._publisher_globals['__old_load_app__'] = old_load_app
            del ZPublisher.WSGIPublisher.__old_load_app__

        # This uses the DB from the dbtab, as configured in setUpDatabase().
        # That DB then gets stored as Zope2.DB and becomes the default.

        import Zope2
        Zope2._began_startup = 0
        Zope2.startup_wsgi()
import unittest

import transaction
import Zope2
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from OFS.Folder import Folder
from OFS.metaconfigure import setDeprecatedManageAddDelete
from OFS.SimpleItem import SimpleItem
from Testing.makerequest import makerequest
from Zope2.App import zcml
from zope.testing import cleanup

Zope2.startup_wsgi()


class EventLogger(object):
    def __init__(self):
        self.reset()

    def reset(self):
        self._called = []

    def trace(self, ob, event):
        self._called.append((ob.getId(), event))

    def called(self):
        return self._called


eventlog = EventLogger()
Exemple #5
0
 def startZope(self):
     # Import Zope
     import Zope2
     Zope2.startup_wsgi()
import transaction
import Zope2
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from OFS.Folder import Folder
from OFS.SimpleItem import SimpleItem
from Testing.makerequest import makerequest
from zope import component
from zope import interface
from Zope2.App import zcml
from zope.interface.interfaces import IObjectEvent
from zope.testing import cleanup


Zope2.startup_wsgi()


class EventLogger(object):
    def __init__(self):
        self.reset()

    def reset(self):
        self._called = []

    def trace(self, ob, event):
        self._called.append((ob.getId(), event.__class__.__name__))

    def called(self):
        return self._called
Exemple #7
0
 def startZope(self):
     # Import Zope
     import Zope2
     Zope2.startup_wsgi()