def setUp(self): # Stack a new DemoStorage on top of the one from z2.STARTUP. self['zodbDB'] = zodb.stackDemoStorage(self.get('zodbDB'), name='PloneSubRequestFixture') # Create a new global registry zca.pushGlobalRegistry() self['configurationContext'] = context = zca.stackConfigurationContext( self.get('configurationContext')) # Load out ZCML from zope.configuration import xmlconfig import plone.subrequest xmlconfig.file('testing.zcml', plone.subrequest, context=context) with z2.zopeApp() as app: # Enable virtual hosting z2.installProduct(app, 'Products.SiteAccess') from Products.SiteAccess.VirtualHostMonster import \ VirtualHostMonster vhm = VirtualHostMonster() app._setObject(vhm.getId(), vhm, suppress_events=True) # With suppress_events=False, this is called twice... vhm.manage_afterAdd(vhm, app) # Setup default content app.manage_addFolder('folder1') make_site(app.folder1) app.folder1.manage_addFolder('folder1A') app.folder1.folder1A.manage_addFolder('folder1Ai') app.folder1.manage_addFolder('folder1B') app.manage_addFolder('folder2') make_site(app.folder2) app.folder2.manage_addFolder('folder2A') app.folder2.folder2A.manage_addFolder('folder2Ai space')
def setUpZCML(self): """Stack a new global registry and load ZCML configuration of CMFDefault and the core set of add-on products into it. """ # Create a new global registry zca.pushGlobalRegistry() from zope.configuration import xmlconfig self['configurationContext'] = context = zca.stackConfigurationContext( self.get('configurationContext')) # Load dependent products's ZCML # CMFDefault doesn't specify dependencies on Products.* packages fully from zope.dottedname.resolve import resolve def loadAll(filename): for p, config in self.products: if not config['loadZCML']: continue try: package = resolve(p) except ImportError: continue try: xmlconfig.file(filename, package, context=context) except IOError: pass loadAll('meta.zcml') loadAll('configure.zcml') loadAll('overrides.zcml')
def setUp(self): # Stack a new DemoStorage on top of the one from z2.STARTUP. self["zodbDB"] = zodb.stackDemoStorage(self.get("zodbDB"), name="PloneSubRequestFixture") # Create a new global registry zca.pushGlobalRegistry() self["configurationContext"] = context = zca.stackConfigurationContext(self.get("configurationContext")) # Load out ZCML from zope.configuration import xmlconfig import plone.subrequest xmlconfig.file("testing.zcml", plone.subrequest, context=context) with z2.zopeApp() as app: # Enable virtual hosting z2.installProduct(app, "Products.SiteAccess") from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster vhm = VirtualHostMonster() app._setObject(vhm.getId(), vhm, suppress_events=True) # With suppress_events=False, this is called twice... vhm.manage_afterAdd(vhm, app) # Setup default content app.manage_addFolder("folder1") make_site(app.folder1) app.folder1.manage_addFolder("folder1A") app.folder1.folder1A.manage_addFolder("folder1Ai") app.folder1.manage_addFolder("folder1B") app.manage_addFolder("folder2") make_site(app.folder2) app.folder2.manage_addFolder("folder2A") app.folder2.folder2A.manage_addFolder("folder2Ai space")
def setUpZCML(self): """Load the basic ZCML configuration from Five. Exposes a resource ``configurationContext`` which can be used to load further ZCML. """ # Push a new global registry so that we can cleanly tear down all ZCML from plone.testing import zca zca.pushGlobalRegistry() # Load something akin to the default site.zcml without actually auto- # loading products self['configurationContext'] = context = zca.stackConfigurationContext( self.get('configurationContext')) from zope.configuration import xmlconfig xmlconfig.string("""\ <configure xmlns="http://namespaces.zope.org/zope" xmlns:meta="http://namespaces.zope.org/meta"> <include package="Products.Five" /> <meta:redefinePermission from="zope2.Public" to="zope.Public" /> <securityPolicy component="Products.Five.security.FiveSecurityPolicy" /> </configure> """, context=context)
def setUpZCML(self): """Stack a new global registry and load ZCML configuration of Plone and the core set of add-on products into it. """ # Create a new global registry zca.pushGlobalRegistry() from zope.configuration import xmlconfig self['configurationContext'] = context = zca.stackConfigurationContext( self.get('configurationContext')) # Load dependent products's ZCML from zope.dottedname.resolve import resolve def loadAll(filename): for p, config in self.products: if not config['loadZCML']: continue try: package = resolve(p) except ImportError: continue try: xmlconfig.file(filename, package, context=context) except IOError: pass loadAll('meta.zcml') loadAll('configure.zcml') loadAll('overrides.zcml') provideAdapter(ldapprops) provideAdapter(usersconfig) provideAdapter(groupsconfig) provideUtility(self['app'], provides=ISiteRoot)
def setUpZCML(self): """Load the basic ZCML configuration from Five. Exposes a resource ``configurationContext`` which can be used to load further ZCML. """ # Push a new global registry so that we can cleanly tear down all ZCML from plone.testing import zca zca.pushGlobalRegistry() # Load something akin to the default site.zcml without actually auto- # loading products self['configurationContext'] = context = zca.stackConfigurationContext(self.get('configurationContext')) from zope.configuration import xmlconfig xmlconfig.string("""\ <configure xmlns="http://namespaces.zope.org/zope" xmlns:meta="http://namespaces.zope.org/meta"> <include package="Products.Five" /> <meta:redefinePermission from="zope2.Public" to="zope.Public" /> <securityPolicy component="Products.Five.security.FiveSecurityPolicy" /> </configure> """, context=context)
def setUp(self): zca.pushGlobalRegistry() import plone.namedfile xmlconfig.file('testing.zcml', plone.namedfile) self['zodbDB'] = zodb.stackDemoStorage(self.get('zodbDB'), name='NamedFileFixture')
def setUp(self): zca.pushGlobalRegistry() import plone.namedfile xmlconfig.file('testing.zcml', plone.namedfile) self['zodbDB'] = zodb.stackDemoStorage( self.get('zodbDB'), name='NamedFileFixture' )
def setUpZCML(self): """Include imio.dms.mail i18n locales before Plone to override plone messages.""" pr = list(self.products) pr.insert(-2, ('imio.dms.mail', { 'loadZCML': True, 'load_only': { 'configure.zcml': 'testing_locales.zcml' } })) self.products = tuple(pr) # Create a new global registry zca.pushGlobalRegistry() from zope.configuration import xmlconfig self['configurationContext'] = context = zca.stackConfigurationContext( self.get('configurationContext')) # Turn off z3c.autoinclude xmlconfig.string("""\ <configure xmlns="http://namespaces.zope.org/zope" xmlns:meta="http://namespaces.zope.org/meta"> <meta:provides feature="disable-autoinclude" /> </configure> """, context=context) from zope.dottedname.resolve import resolve def loadAll(filename): for p, config in self.products: if not config['loadZCML']: continue # we don't want to load overrides.zcml now ! if 'load_only' in config and filename not in config[ 'load_only']: continue try: package = resolve(p) except ImportError: continue try: if 'load_only' in config and filename in config[ 'load_only']: xmlconfig.file(config['load_only'][filename], package, context=context) else: xmlconfig.file(filename, package, context=context) except IOError: pass loadAll('meta.zcml') loadAll('configure.zcml') loadAll('overrides.zcml')
def setUp(self): # Push a new configuration context so that it's possible to re-import # ZCML files after tear-down (in Plone tests, PloneSandboxLayer does # this for you) self['configurationContext'] = configurationContext = ( zca.stackConfigurationContext(self['configurationContext'], name='ZAMQP-Testing')) zca.pushGlobalRegistry() xmlconfig.file('testing.zcml', collective.zamqp, context=self['configurationContext'])
def setUp(self): BeakerConfigLayer.setUp() zca.pushGlobalRegistry() self['configurationContext'] = context = zca.stackConfigurationContext(self.get('configurationContext')) import collective.confirm_email xmlconfig.file('configure.zcml', package=collective.confirm_email, context=context) from collective.confirm_email.nonce import NonceManager from collective.confirm_email.interfaces import INonceManager provideUtility(NonceManager(), provides=INonceManager) provideUtility(MockMailHost('MailHost'), provides=IMailHost)
def setUp(self): zca.pushGlobalRegistry() self.configurationContext = zca.stackConfigurationContext() import ftw.inflator xmlconfig.file('meta.zcml', ftw.inflator, context=self.configurationContext) with zopeApp() as app: self.app = app self.browser = Browser(app) self.browser.handleErrors = False self.browser.addHeader('Authorization', 'Basic %s:%s' % ( SITE_OWNER_NAME, SITE_OWNER_PASSWORD))
def setUp(self): """run ldapadd for list of ldifs """ if not os.environ.get('node.ext.ldap.testldap.skip_zca_hook'): zca.pushGlobalRegistry() read_env(self) self['ucfg'] = self.ucfg self['gcfg'] = self.gcfg for ldif in self.ldifs: print("Adding ldif %s: " % ldif) cmd = [self.ldapaddbin, '-f', ldif, '-x', '-D', self['binddn'], '-w', self['bindpw'], '-c', '-a', '-H', self['uris']] retcode = subprocess.call(cmd) print("done. %s" % retcode)
def pushGlobalRegistry(portal, new=None, name=None): """Set a new global component registry that uses the current registry as a base. If you use this, you *must* call ``popGlobalRegistry()`` to restore the original state. If ``new`` is not given, a new registry is created. If given, you must provide a ``zope.component.globalregistry.BaseGlobalComponents`` object. Returns the new registry. Also ensure that the persistent component registry at ``portal`` has the new global registry as its base. """ from zope.site.hooks import setSite, getSite, setHooks site = getSite() localSiteManager = portal.getSiteManager() current = zca.pushGlobalRegistry(new=new) if current not in localSiteManager.__bases__: localSiteManager.__bases__ = (current, ) if site is not None: setHooks() setSite(site) return current
def setUpZCML(self): """Stack a new global registry and load ZCML configuration of Plone and the core set of add-on products into it. Also set the ``disable-autoinclude`` ZCML feature so that Plone does not attempt to auto-load ZCML using ``z3c.autoinclude``. """ # Create a new global registry zca.pushGlobalRegistry() from zope.configuration import xmlconfig self["configurationContext"] = context = zca.stackConfigurationContext(self.get("configurationContext")) # Turn off z3c.autoinclude xmlconfig.string( """\ <configure xmlns="http://namespaces.zope.org/zope" xmlns:meta="http://namespaces.zope.org/meta"> <meta:provides feature="disable-autoinclude" /> </configure> """, context=context, ) # Load dependent products's ZCML - Plone doesn't specify dependencies # on Products.* packages fully from zope.dottedname.resolve import resolve def loadAll(filename): for p, config in self.products: if not config["loadZCML"]: continue try: package = resolve(p) except ImportError: continue try: xmlconfig.file(filename, package, context=context) except IOError: pass loadAll("meta.zcml") loadAll("configure.zcml") loadAll("overrides.zcml")
def setUp(self): zca.pushGlobalRegistry() self.configurationContext = zca.stackConfigurationContext() import ftw.inflator xmlconfig.file('meta.zcml', ftw.inflator, context=self.configurationContext) with zopeApp() as app: self.app = app self.browser = Browser(app) self.browser.handleErrors = False self.browser.addHeader( 'Authorization', 'Basic %s:%s' % (SITE_OWNER_NAME, SITE_OWNER_PASSWORD))
def setUp(self): """run ldapadd for list of ldifs """ if not os.environ.get('node.ext.ldap.testldap.skip_zca_hook'): zca.pushGlobalRegistry() read_env(self) self['ucfg'] = self.ucfg self['gcfg'] = self.gcfg for ldif in self.ldifs: print("Adding ldif %s: " % ldif) cmd = [ self.ldapaddbin, '-f', ldif, '-x', '-D', self['binddn'], '-w', self['bindpw'], '-c', '-a', '-H', self['uris'] ] retcode = subprocess.call(cmd) print("done. %s" % retcode)
def setUp(self): self['configurationContext'] = zca.stackConfigurationContext( self.get('configurationContext')) zca.pushGlobalRegistry() import collective.ploneupgradecheck self.load_zcml_file('configure.zcml', collective.ploneupgradecheck) self.my_package_path = os.path.join(os.path.dirname(__file__), 'tests', 'my.package') file_registry = getUtility(IFileRegistry) file_registry.clear() file_registry.load(self.my_package_path) import_registry = getUtility(IImportRegistry) import_registry.clear()
def setUpZCML(self): """Stack a new global registry and load ZCML configuration of Plone and the core set of add-on products into it. Also set the ``disable-autoinclude`` ZCML feature so that Plone does not attempt to auto-load ZCML using ``z3c.autoinclude``. """ # Create a new global registry zca.pushGlobalRegistry() from zope.configuration import xmlconfig self['configurationContext'] = context = zca.stackConfigurationContext( self.get('configurationContext')) # Turn off z3c.autoinclude xmlconfig.string("""\ <configure xmlns="http://namespaces.zope.org/zope" xmlns:meta="http://namespaces.zope.org/meta"> <meta:provides feature="disable-autoinclude" /> </configure> """, context=context) # Load dependent products's ZCML - Plone doesn't specify dependencies # on Products.* packages fully from zope.dottedname.resolve import resolve def loadAll(filename): for p, config in self.products: if not config['loadZCML']: continue try: package = resolve(p) except ImportError: continue try: xmlconfig.file(filename, package, context=context) except IOError: pass loadAll('meta.zcml') loadAll('configure.zcml') loadAll('overrides.zcml')
def setUp(self): """run ldapadd for list of ldifs """ # Create a new global registry if not os.environ.get('node.ext.ldap.testldap.skip_zca_hook'): import zope.testing.cleanup zope.testing.cleanup.cleanUp() zca.pushGlobalRegistry() read_env(self) self['ucfg'] = self.ucfg self['gcfg'] = self.gcfg print for ldif in self.ldifs: print "Adding ldif %s: " % (ldif,), cmd = [self.ldapaddbin, '-f', ldif, '-x', '-D', self['binddn'], '-w', self['bindpw'], '-c', '-a', '-H', self['uris']] retcode = subprocess.call(cmd) print "done. %s" % retcode
def test_adding_class_declaration(self): # Create a new global registry zca.pushGlobalRegistry() from zope.configuration import xmlconfig self.layer['configurationContext'] = context = zca.stackConfigurationContext(self.layer.get('configurationContext')) xmlconfig.string("""\ <configure xmlns="http://namespaces.zope.org/zope" xmlns:diversion="http://namespaces.plone.org/diversion"> <diversion:class old="Products.example.oldlocation" new="collective.example.shiny" /> </configure> """, context=context) self.assertEqual(diversion.diversions['Products.example', 'oldlocation'], ('collective.example', 'shiny'))
def setUp(self): self.app = self.layer.get('app') zca.pushGlobalRegistry() # set up all three types of directory package_dir_path = os.path.join(test_dir_path, 'demo', 'foo') self.package_dir = dir = FilesystemResourceDirectory(package_dir_path) provideUtility(dir, provides=IResourceDirectory, name=u'++demo++foo') self.global_dir = dir = FilesystemResourceDirectory(test_dir_path) provideUtility(dir, provides=IResourceDirectory, name=u'') root = BTreeFolder2('portal_resources') self.app._setOb('portal_resources', root) root._setOb('demo', BTreeFolder2('demo')) root.demo._setOb('foo', BTreeFolder2('foo')) self.zodb_dir = dir = PersistentResourceDirectory(root) provideUtility(dir, provides=IResourceDirectory, name=u'persistent') # We don't want a false positive for the following. provideUtility(dir, provides=IResourceDirectory, name=u'++bogus++foo')
def setUp(self): self['zodbDB'] = zodb.stackDemoStorage( self.get('zodbDB'), name='CMFAppLayer', ) with z2.zopeApp() as app: self.setUpTestUserContext(app) for pkg in self.PRODUCTS: z2.installProduct(app, pkg) self.setUpSite(app) transaction.commit() global_components = zca.pushGlobalRegistry() site = self.get('site') local_components = site.getSiteManager() if global_components not in local_components.__bases__: local_components.__bases__ = (global_components,)
def setUp(self): zca.pushGlobalRegistry()
def setUp(self): zca.pushGlobalRegistry() self.configurationContext = zca.stackConfigurationContext() import ftw.inflator xmlconfig.file('meta.zcml', ftw.inflator, context=self.configurationContext)
def testSetUp(self): zca.pushGlobalRegistry() self['configurationContext'] = zca.stackConfigurationContext( self.get('configurationContext'), name='ftw.builder:PACKAGE_BUILDER_LAYER')
def setUp(self): zca.pushGlobalRegistry() provideAdapter(TestStorageLocator, adapts=[Interface])
def setUp(self): zca.pushGlobalRegistry() import plone.namedfile xmlconfig.file('testing.zcml', plone.namedfile)
def setUp(self): self.app = self.layer.get('app') zca.pushGlobalRegistry()
def testSetUp(self): zca.pushGlobalRegistry()
def testSetUp(self): self['configurationContext'] = zca.stackConfigurationContext( self.get('configurationContext'), name='ftw.testing.component_registry_isolation') zca.pushGlobalRegistry()