Esempio n. 1
0
    def tearDown(self):
        # Zap the stacked ZODB
        self['zodbDB'].close()
        del self['zodbDB']

        # Zap the stacked zca context
        zca.popGlobalRegistry()
Esempio n. 2
0
    def tearDown(self):
        # Zap the stacked ZODB
        self['zodbDB'].close()
        del self['zodbDB']

        # Zap the stacked zca context
        zca.popGlobalRegistry()
Esempio n. 3
0
    def tearDown(self):
        """remove previously added ldifs
        """
        read_env(self)
        for ldif in self.ldifs:
            print "Removing ldif %s recursively: " % (ldif, ),
            with open(ldif) as ldif:
                dns = [
                    x.strip().split(' ', 1)[1] for x in ldif
                    if x.startswith('dn: ')
                ]
            cmd = [
                self.ldapdeletebin, '-x', '-D', self['binddn'], '-c', '-r',
                '-w', self['bindpw'], '-H', self['uris']
            ] + dns
            retcode = subprocess.call(cmd, stderr=subprocess.PIPE)
            print "done. %s" % retcode
        for key in ('ucfg', 'gcfg'):
            if key in self:
                del self[key]

        if not os.environ.get('node.ext.ldap.testldap.skip_zca_hook'):
            # XXX: fails to pop global registry in Zope 2. Why?
            try:
                zca.popGlobalRegistry()
                print 80 * '*'
                print "pop global registry"
            except Exception, e:
                print 80 * '*'
                print "pop global registry failed"
                print e
                print 80 * '*'
Esempio n. 4
0
    def tearDown(self):
        """remove previously added ldifs
        """
        read_env(self)
        for ldif in self.ldifs:
            print "Removing ldif %s recursively: " % (ldif,),
            with open(ldif) as ldif:
                dns = [x.strip().split(' ', 1)[1] for x in ldif if
                       x.startswith('dn: ')]
            cmd = [self.ldapdeletebin, '-x', '-D', self['binddn'], '-c', '-r',
                   '-w', self['bindpw'], '-H', self['uris']] + dns
            retcode = subprocess.call(cmd, stderr=subprocess.PIPE)
            print "done. %s" % retcode
        for key in ('ucfg', 'gcfg'):
            if key in self:
                del self[key]

        if not os.environ.get('node.ext.ldap.testldap.skip_zca_hook'):
            # XXX: fails to pop global registry in Zope 2. Why?
            try:
                zca.popGlobalRegistry()
                print 80 * '*'
                print "pop global registry"
            except Exception, e:
                print 80 * '*'
                print "pop global registry failed"
                print e
                print 80 * '*'
Esempio n. 5
0
    def tearDown(self):
        # Zap the stacked configuration context
        zca.popGlobalRegistry()
        del self['configurationContext']

        # Zap the stacked ZODB
        self['zodbDB'].close()
        del self['zodbDB']
Esempio n. 6
0
    def tearDown(self):
        # Zap the stacked configuration context
        zca.popGlobalRegistry()
        del self['configurationContext']

        # Zap the stacked ZODB
        self['zodbDB'].close()
        del self['zodbDB']
Esempio n. 7
0
    def tearDownZCML(self):
        """Pop the global component registry stack, effectively unregistering
        all global components registered during layer setup.
        """
        # Pop the global registry
        zca.popGlobalRegistry()

        # Zap the stacked configuration context
        del self['configurationContext']
Esempio n. 8
0
    def tearDownZCML(self):
        """Pop the global component registry stack, effectively unregistering
        all global components registered during layer setup.
        """
        # Pop the global registry
        zca.popGlobalRegistry()

        # Zap the stacked configuration context
        del self['configurationContext']
Esempio n. 9
0
    def tearDownZCML(self):
        """Tear down the component registry and delete the
        ``configurationContext`` resource.
        """
        # Delete the (possibly stacked) configuration context
        del self['configurationContext']

        # Zap all globally loaded ZCML
        from plone.testing import zca
        zca.popGlobalRegistry()
Esempio n. 10
0
    def tearDownZCML(self):
        """Tear down the component registry and delete the
        ``configurationContext`` resource.
        """
        # Delete the (possibly stacked) configuration context
        del self['configurationContext']

        # Zap all globally loaded ZCML
        from plone.testing import zca
        zca.popGlobalRegistry()
Esempio n. 11
0
def popGlobalRegistry(portal):
    """Restore the global component registry form the top of the stack, as
    set with ``pushGlobalRegistry()``.

    Also ensure that the persistent component registry at ``portal`` has the
    new global registry as its base.
    """

    # First, check if the component site has the global site manager in its
    # bases. If so, that site manager is about to disappear, so set its
    # base(s) as the new base(s) for the local site manager.

    from zope.component import getGlobalSiteManager
    globalSiteManager = getGlobalSiteManager()

    gsmBases = globalSiteManager.__bases__

    from zope.site.hooks import setSite, getSite, setHooks
    site = getSite()

    localSiteManager = portal.getSiteManager()

    bases = []
    changed = False
    for base in localSiteManager.__bases__:
        if base is globalSiteManager:
            bases.extend(gsmBases)
            changed = True
        else:
            bases.append(base)

    if changed:
        localSiteManager.__bases__ = tuple(bases)

    # Now pop the registry. We need to do it in this somewhat convoluted way
    # to avoid the risk of unpickling errors

    previous = zca.popGlobalRegistry()

    if site is not None:
        setHooks()
        setSite(site)

    return previous
Esempio n. 12
0
def popGlobalRegistry(portal):
    """Restore the global component registry form the top of the stack, as
    set with ``pushGlobalRegistry()``.

    Also ensure that the persistent component registry at ``portal`` has the
    new global registry as its base.
    """

    # First, check if the component site has the global site manager in its
    # bases. If so, that site manager is about to disappear, so set its
    # base(s) as the new base(s) for the local site manager.

    from zope.component import getGlobalSiteManager
    globalSiteManager = getGlobalSiteManager()

    gsmBases = globalSiteManager.__bases__

    from zope.site.hooks import setSite, getSite, setHooks
    site = getSite()

    localSiteManager = portal.getSiteManager()

    bases = []
    changed = False
    for base in localSiteManager.__bases__:
        if base is globalSiteManager:
            bases.extend(gsmBases)
            changed = True
        else:
            bases.append(base)

    if changed:
        localSiteManager.__bases__ = tuple(bases)

    # Now pop the registry. We need to do it in this somewhat convoluted way
    # to avoid the risk of unpickling errors

    previous = zca.popGlobalRegistry()

    if site is not None:
        setHooks()
        setSite(site)

    return previous
Esempio n. 13
0
def popGlobalRegistry(silvaroot):
    """Restore the global component registry form the top of the stack, as
    set with ``pushGlobalRegistry()``.

    Also ensure that the persistent component registry at ``silvaroot`` has the
    new global registry as its base.
    """

    from zope.app.component.hooks import setSite, getSite, setHooks
    site = getSite()

    # Now pop the registry. We need to do it in this somewhat convoluted way
    # to avoid the risk of unpickling errors

    previous = zca.popGlobalRegistry()

    if site is not None:
        setHooks()
        setSite(site)

    return previous
Esempio n. 14
0
 def tearDown(self):
     zca.popGlobalRegistry()
Esempio n. 15
0
 def tearDown(self):
     zca.popGlobalRegistry()
     self.configurationContext = None
Esempio n. 16
0
 def tearDown(self):
     # Zap the stacked zca context
     zca.popGlobalRegistry()
Esempio n. 17
0
 def tearDown(self):
     zca.popGlobalRegistry()
     if hasattr(self, 'configurationContext'):
         del self['configurationContext']
     zope.component.testing.tearDown(self)
Esempio n. 18
0
 def tearDown(self):
     # remove the stacked storage layer
     self['zodbDB'].close()
     del(self['zodbDB'])
     zca.popGlobalRegistry()
 def tearDown(self):
     zca.popGlobalRegistry()
     del self['configurationContext']
Esempio n. 20
0
 def tearDown(self):
     zca.popGlobalRegistry()
     if hasattr(self, 'configurationContext'):
         del self['configurationContext']
     zope.component.testing.tearDown(self)
Esempio n. 21
0
 def tearDown(self):
     zca.popGlobalRegistry()
 def tearDown(self):
     zca.popGlobalRegistry()
     self.configurationContext = None