コード例 #1
0
ファイル: autoinclude.py プロジェクト: gotcha/sauna.reload
def include_deferred_deps():
    # Build and execute a configuration file to include meta, configuration and
    # overrides for dependencies of the deferred development packages.
    deps = get_deferred_deps_info()
    config = u"""\
<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:zcml="http://namespaces.zope.org/zcml">

    """ + u"".join([u"""<include
        zcml:condition="not-have disable-autoinclude"
        package="%s"
        file="meta.zcml"
        />""" % name for name in deps.get("meta.zcml", ())]) + """

    """ + u"".join([u"""<include
        zcml:condition="not-have disable-autoinclude"
        package="%s"
        file="configure.zcml"
        />""" % name for name in deps.get("configure.zcml", ())]) + """

    """ + u"".join([u"""<includeOverrides
        zcml:condition="not-have disable-autoinclude"
        package="%s"
        file="overrides.zcml"
        />""" % name for name in deps.get("overrides.zcml", ())]) + """

</configure>"""
    load_string(config)
コード例 #2
0
    def setUp(self):
        self.portal = self.layer['portal']
        self.request = self.layer['request']
        self.registry = EventsRegistry

        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        name = self.portal.invokeFactory(id='doc1',
                                         title='Document 1',
                                         type_name='Document')

        self.document = self.portal[name]

        #
        # Subscribers
        #
        configure = """
        <configure
          xmlns="http://namespaces.zope.org/zope">

          <subscriber
            for="OFS.interfaces.ISimpleItem
                 plone.app.discussion.interfaces.IReplyAddedEvent"
            handler="plone.app.discussion.tests.test_events.reply_added"
            />

          <subscriber
            for="OFS.interfaces.ISimpleItem
                 plone.app.discussion.interfaces.IReplyRemovedEvent"
            handler="plone.app.discussion.tests.test_events.reply_removed"
            />

         </configure>
        """
        zcml.load_config("configure.zcml", Products.Five)
        zcml.load_string(configure)
コード例 #3
0
ファイル: testing.py プロジェクト: bendavis78/zope
    def testSetUp(cls):
        import Zope2.App
        import AccessControl
        import Products.Five
        import Products.GenericSetup
        import Products.CMFCore
        import Products.CMFCore.exportimport

        try:
            zcml.load_config('meta.zcml', Zope2.App)
        except IOError:  # Zope <= 2.12.x
            pass

        zcml.load_config('meta.zcml', Products.Five)

        try:
            zcml.load_config('permissions.zcml', AccessControl)
        except IOError:  # Zope <= 2.12.x
            pass

        zcml.load_config('permissions.zcml', Products.Five)

        zcml.load_config('meta.zcml', Products.GenericSetup)
        zcml.load_config('configure.zcml', Products.GenericSetup)
        zcml.load_config('permissions.zcml', Products.CMFCore)
        zcml.load_config('tool.zcml', Products.CMFCore)
        zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
        zcml.load_string(_DUMMY_ZCML)
        setHooks()
コード例 #4
0
    def setUp(self):

        # Setup sandbox
        self.portal = self.layer['portal']
        self.request = self.layer['request']
        self.registry = EventsRegistry

        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        self.document = self.portal['doc1']

        #
        # Subscribers
        #
        configure = """
        <configure
          xmlns="http://namespaces.zope.org/zope">

          <subscriber
            for="OFS.interfaces.ISimpleItem
                 plone.app.discussion.interfaces.ICommentAddedEvent"
            handler="plone.app.discussion.tests.test_events.comment_added"
            />

          <subscriber
            for="OFS.interfaces.ISimpleItem
                 plone.app.discussion.interfaces.ICommentRemovedEvent"
            handler="plone.app.discussion.tests.test_events.comment_removed"
            />

         </configure>
        """
        zcml.load_config('configure.zcml', Products.Five)
        zcml.load_string(configure)
コード例 #5
0
    def setUp(self):

        # Setup sandbox
        self.portal = self.layer['portal']
        self.request = self.layer['request']
        self.registry = EventsRegistry

        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        self.document = self.portal['doc1']

        #
        # Subscribers
        #
        configure = """
        <configure
          xmlns="http://namespaces.zope.org/zope">

          <subscriber
            for="OFS.interfaces.ISimpleItem
                 plone.app.discussion.interfaces.ICommentAddedEvent"
            handler="plone.app.discussion.tests.test_events.comment_added"
            />

          <subscriber
            for="OFS.interfaces.ISimpleItem
                 plone.app.discussion.interfaces.ICommentRemovedEvent"
            handler="plone.app.discussion.tests.test_events.comment_removed"
            />

         </configure>
        """
        zcml.load_config("configure.zcml", Products.Five)
        zcml.load_string(configure)
コード例 #6
0
ファイル: ZenDocTest.py プロジェクト: zenoss/zenoss-prodbin
def load_unittest_site(force=False):
    """
    Custom version of zcml.load_site() that will force the provision of the
    "unittests" feature.
    """
    if _zcml._initialized and not force:
        return
    _zcml._initialized = True

    import Globals
    Globals.INSTANCE_HOME

    # load instance site configuration file
    site_zcml = os.path.join(Globals.INSTANCE_HOME, "etc", "site.zcml")

    if not os.path.exists(site_zcml):
        # check for zope installation home skel during running unit tests
        import Zope2.utilities
        zope_utils = os.path.dirname(Zope2.utilities.__file__)
        site_zcml = os.path.join(zope_utils, "skel", "etc", "site.zcml")

    # Blow away existing context (this normally happens in a call to load_site)
    _zcml._context = None
    # Load the snippet claiming the unittests feature is provided
    _zcml.load_string("""
        <configure xmlns="http://namespaces.zope.org/meta">
            <provides feature="unittests"/>
            <include package="Products.Five" file="meta.zcml" />
            <include package="Products.Zing"/>
        </configure>
    """)
    # Now load_site as usual, except keep the existing context
    _zcml._context = xmlconfig.file(site_zcml, None, _zcml._context)
コード例 #7
0
ファイル: ZenDocTest.py プロジェクト: bbc/zenoss-prodbin
def load_unittest_site(force=False):
    """
    Custom version of zcml.load_site() that will force the provision of the
    "unittests" feature.
    """
    if _zcml._initialized and not force:
        return
    _zcml._initialized = True

    import Globals
    Globals.INSTANCE_HOME

    # load instance site configuration file
    site_zcml = os.path.join(Globals.INSTANCE_HOME, "etc", "site.zcml")

    if not os.path.exists(site_zcml):
        # check for zope installation home skel during running unit tests
        import Zope2.utilities
        zope_utils = os.path.dirname(Zope2.utilities.__file__)
        site_zcml = os.path.join(zope_utils, "skel", "etc", "site.zcml")

    # Blow away existing context (this normally happens in a call to load_site)
    _zcml._context = None
    # Load the snippet claiming the unittests feature is provided
    _zcml.load_string("""
        <configure xmlns="http://namespaces.zope.org/meta">
            <provides feature="unittests"/>
        </configure>
    """)
    # Now load_site as usual, except keep the existing context
    _zcml._context = xmlconfig.file(site_zcml, None, _zcml._context)
コード例 #8
0
ファイル: testing.py プロジェクト: CGTIC/Plone_SP
    def testSetUp(cls):
        import Zope2.App
        import AccessControl
        import Products.Five
        import Products.GenericSetup
        import Products.CMFCore
        import Products.CMFCore.exportimport

        try:
            zcml.load_config('meta.zcml', Zope2.App)
        except IOError:  # Zope <= 2.12.x
            pass

        zcml.load_config('meta.zcml', Products.Five)

        try:
            zcml.load_config('permissions.zcml', AccessControl)
        except IOError:  # Zope <= 2.12.x
            pass

        zcml.load_config('permissions.zcml', Products.Five)

        zcml.load_config('meta.zcml', Products.GenericSetup)
        zcml.load_config('configure.zcml', Products.GenericSetup)
        zcml.load_config('permissions.zcml', Products.CMFCore)
        zcml.load_config('tool.zcml', Products.CMFCore)
        zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
        zcml.load_string(_DUMMY_ZCML)
        setHooks()
コード例 #9
0
ファイル: utils.py プロジェクト: RedTurtle/collective.solr
def loadZCMLString(string):
    # Unset current site for Zope 2.13
    saved = getSite()
    setSite(None)
    try:
        zcml.load_string(string)
    finally:
        setSite(saved)
コード例 #10
0
def loadZCMLString(string):
    # Unset current site for Zope 2.13
    saved = getSite()
    setSite(None)
    try:
        zcml.load_string(string)
    finally:
        setSite(saved)
コード例 #11
0
ファイル: test_stepzcml.py プロジェクト: pchanxxx/msc-buidout
 def testOneStepImport(self):
     zcml.load_string(ONE_STEP_ZCML)
     self.assertEqual(_import_step_registry.listSteps(), [u"Products.GenericSetup.teststep"])
     info = _import_step_registry.getStepMetadata(u"Products.GenericSetup.teststep")
     self.assertEqual(info["description"], u"step description")
     self.assertEqual(info["title"], u"step title")
     self.assertEqual(info["handler"], "Products.GenericSetup.initialize")
     self.assertEqual(info["id"], u"Products.GenericSetup.teststep")
コード例 #12
0
 def setUp(cls):
     configure_zcml = '''\
     <configure
          xmlns="http://namespaces.zope.org/zope"
          xmlns:browser="http://namespaces.zope.org/browser"
          package="kss.core.tests.test_ttwapi">
       <subscriber handler=".objectModifiedThruKSSView" />
     </configure>'''
     zcml.load_string(configure_zcml)
コード例 #13
0
 def testOneStepImport(self):
     zcml.load_string(ONE_STEP_ZCML)
     self.assertEqual(_import_step_registry.listSteps(),
                      [u'Products.GenericSetup.teststep'])
     info = _import_step_registry.getStepMetadata(
         u'Products.GenericSetup.teststep')
     self.assertEqual(info['description'], u'step description')
     self.assertEqual(info['title'], u'step title')
     self.assertEqual(info['handler'], 'Products.GenericSetup.initialize')
     self.assertEqual(info['id'], u'Products.GenericSetup.teststep')
コード例 #14
0
    def testSavedVersionHistory(self):
        # check current version of report (should be empty)
        self.checkForExistingCallHomeData()

        # set up test version history collector
        zcml.load_string(TEST_VERSION_HISTORY_COLLECTOR)

        # generate callhome
        chd = CallHomeData(self.dmd, True)
        data = chd.getData()
        firstReportDate = data[REPORT_DATE_KEY]

        time.sleep(1)

        # make sure version history record is present and correct
        self.assertTrue(VERSION_HISTORIES_KEY in data)
        versionHistories = data[VERSION_HISTORIES_KEY]
        self.assertTrue(TEST_VERSION_HISTORY_ENTITY in versionHistories)
        versionHistory = versionHistories[TEST_VERSION_HISTORY_ENTITY]
        self.assertTrue(TEST_VERSION_1 in versionHistory)
        historyRecord = versionHistory[TEST_VERSION_1]
        self.assertTrue(VERSION_START_KEY in historyRecord)
        self.assertEquals(firstReportDate, historyRecord[VERSION_START_KEY])

        # The cycler code is where the saving of
        # callhome data in ZODB occurs. We'll have
        # to mimic that again here.
        self.dmd.callHome = PersistentCallHomeData()
        self.dmd.callHome.metrics = json.dumps(data)

        # update the version history
        global TEST_CURRENT_VERSION
        TEST_CURRENT_VERSION = TEST_VERSION_2

        # generate callhome again
        chd = CallHomeData(self.dmd, True)
        data = chd.getData()
        secondReportDate = data[REPORT_DATE_KEY]

        # make sure a second version history record exists
        self.assertTrue(VERSION_HISTORIES_KEY in data)
        versionHistories = data[VERSION_HISTORIES_KEY]
        self.assertTrue(TEST_VERSION_HISTORY_ENTITY in versionHistories)
        versionHistory = versionHistories[TEST_VERSION_HISTORY_ENTITY]
        self.assertTrue(TEST_VERSION_1 in versionHistory)
        historyRecord = versionHistory[TEST_VERSION_1]
        self.assertTrue(VERSION_START_KEY in historyRecord)
        self.assertEquals(firstReportDate, historyRecord[VERSION_START_KEY])
        self.assertTrue(TEST_VERSION_2 in versionHistory)
        historyRecord = versionHistory[TEST_VERSION_2]
        self.assertTrue(VERSION_START_KEY in historyRecord)
        self.assertEquals(secondReportDate, historyRecord[VERSION_START_KEY])
コード例 #15
0
ファイル: test_zcml.py プロジェクト: pigaov10/plone4.3
 def testWithDependency(self):
     zcml.load_string("""
     <configure xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
                i18n_domain="genericsetup">
      <genericsetup:importStep
          name="name"
          title="title"
          description="description"
          handler="Products.GenericSetup.tests.test_zcml.dummy_importstep">
       <depends name="something.else"/>
      </genericsetup:importStep>
     </configure>""")
     data=_import_step_registry.getStepMetadata(u'name')
     self.assertEqual(data["dependencies"], (u"something.else",))
コード例 #16
0
 def testWithDependency(self):
     zcml.load_string("""
     <configure xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
                i18n_domain="genericsetup">
      <genericsetup:importStep
          name="name"
          title="title"
          description="description"
          handler="Products.GenericSetup.tests.test_zcml.dummy_importstep">
       <depends name="something.else"/>
      </genericsetup:importStep>
     </configure>""")
     data = _import_step_registry.getStepMetadata(u'name')
     self.assertEqual(data["dependencies"], (u"something.else", ))
コード例 #17
0
    def test_hourly_job(self):
        zcml.load_string(self.zcml_template % '''
        <schedule:job
            view="dummy-view"
            unit="hour"
            />
        ''')

        jobs = schedule.jobs
        self.assertEquals(len(jobs), 1)
        job = jobs[0]
        self.assertEquals(job.interval, 1)
        self.assertEquals(job.unit, 'hours')
        self.assertEquals(job.at_time, None)
コード例 #18
0
ファイル: test_stepzcml.py プロジェクト: CGTIC/Plone_SP
 def testOneStepImport(self):
     zcml.load_string(ONE_STEP_ZCML)
     self.assertEqual(_import_step_registry.listSteps(),
                      [u'Products.GenericSetup.teststep'])
     info = _import_step_registry.getStepMetadata(
         u'Products.GenericSetup.teststep')
     self.assertEqual(info['description'],
                      u'step description')
     self.assertEqual(info['title'],
                      u'step title')
     self.assertEqual(info['handler'],
                      'Products.GenericSetup.initialize')
     self.assertEqual(info['id'],
                      u'Products.GenericSetup.teststep')
コード例 #19
0
    def setUp(cls):
        import Products.Five
        import Products.GenericSetup
        import Products.CMFCore
        import Products.CMFCore.exportimport
        import Products.DCWorkflow

        zcml.load_config('meta.zcml', Products.Five)
        zcml.load_config('meta.zcml', Products.GenericSetup)
        zcml.load_config('configure.zcml', Products.Five)
        zcml.load_config('configure.zcml', Products.GenericSetup)
        zcml.load_config('tool.zcml', Products.CMFCore)
        zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
        zcml.load_config('tool.zcml', Products.DCWorkflow)
        zcml.load_config('exportimport.zcml', Products.DCWorkflow)
        zcml.load_string(_DUMMY_ZCML)
コード例 #20
0
ファイル: testing.py プロジェクト: goschtl/zope
    def setUp(cls):
        import Products.Five
        import Products.GenericSetup
        import Products.CMFCore
        import Products.CMFCore.exportimport
        import Products.DCWorkflow

        zcml.load_config('meta.zcml', Products.Five)
        zcml.load_config('meta.zcml', Products.GenericSetup)
        zcml.load_config('configure.zcml', Products.Five)
        zcml.load_config('configure.zcml', Products.GenericSetup)
        zcml.load_config('tool.zcml', Products.CMFCore)
        zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
        zcml.load_config('tool.zcml', Products.DCWorkflow)
        zcml.load_config('exportimport.zcml', Products.DCWorkflow)
        zcml.load_string(_DUMMY_ZCML)
コード例 #21
0
def setUp(test=None):
    configure_zcml = '''\
    <configure
         xmlns="http://namespaces.zope.org/zope"
         xmlns:browser="http://namespaces.zope.org/browser"
         package="kss.core.tests.test_kssview_functional">
      <browser:page
          for="*"
          name="testkssview"
          class=".TestKSSView"
          permission="zope.Public"
          />
      <subscriber handler=".objectModifiedThruKSSView" />
    </configure>'''
    zcml.load_config('configure.zcml', Products.Five)
    zcml.load_string(configure_zcml)
    setHooks()
コード例 #22
0
ファイル: test_zcml.py プロジェクト: pigaov10/plone4.3
 def testRegistration(self):
     zcml.load_string("""\
     <configure xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
                i18n_domain="genericsetup">
     <genericsetup:exportStep
         name="name"
         title="title"
         description="description"
         handler="Products.GenericSetup.tests.test_zcml.dummy_exportstep"
         />
     </configure>""")
     self.assertEqual( _export_step_registry.listSteps(), [u'name'])
     data=_export_step_registry.getStepMetadata(u'name')
     self.assertEqual(data["handler"],
             'Products.GenericSetup.tests.test_zcml.dummy_exportstep')
     self.assertEqual(data["description"], u"description")
     self.assertEqual(data["title"], u"title")
     self.assertEqual(data["id"], u"name")
コード例 #23
0
 def testRegistration(self):
     zcml.load_string("""\
     <configure xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
                i18n_domain="genericsetup">
     <genericsetup:exportStep
         name="name"
         title="title"
         description="description"
         handler="Products.GenericSetup.tests.test_zcml.dummy_exportstep"
         />
     </configure>""")
     self.assertEqual(_export_step_registry.listSteps(), [u'name'])
     data = _export_step_registry.getStepMetadata(u'name')
     expected = 'Products.GenericSetup.tests.test_zcml.dummy_exportstep'
     self.assertEqual(data["handler"], expected)
     self.assertEqual(data["description"], u"description")
     self.assertEqual(data["title"], u"title")
     self.assertEqual(data["id"], u"name")
コード例 #24
0
ファイル: test_guid.py プロジェクト: zenoss/zenoss-prodbin
 def test_device_move(self):
     zcml.load_string("""
     <configure xmlns="http://namespaces.zope.org/zope">
         <adapter
             for="Products.ZenModel.Device.Device"
             provides="Products.ZenUtils.guid.interfaces.IGUIDManager"
             factory="Products.ZenUtils.guid.guid.GUIDManager"
             />
     </configure>
     """)
     source = self.dmd.Devices.createOrganizer('source')
     dest = self.dmd.Devices.createOrganizer('dest')
     dev = source.createInstance('testdevice')
     guid = IGlobalIdentifier(dev).guid
     source.moveDevices(dest.getOrganizerName(), 'testdevice')
     newdev = dest.devices.testdevice
     newguid = IGlobalIdentifier(newdev).guid
     self.assertEqual(guid, newguid)
コード例 #25
0
 def testNoDependencies(self):
     zcml.load_string("""\
     <configure xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
                i18n_domain="genericsetup">
      <genericsetup:importStep
          name="name"
          title="title"
          description="description"
          handler="Products.GenericSetup.tests.test_zcml.dummy_importstep">
      </genericsetup:importStep>
     </configure>""")
     self.assertEqual( _import_step_registry.listSteps(), [u'name'])
     data=_import_step_registry.getStepMetadata(u'name')
     self.assertEqual(data["handler"],
             'Products.GenericSetup.tests.test_zcml.dummy_importstep')
     self.assertEqual(data["description"], u"description")
     self.assertEqual(data["title"], u"title")
     self.assertEqual(data["dependencies"], ())
     self.assertEqual(data["id"], u"name")
コード例 #26
0
 def testNoDependencies(self):
     zcml.load_string("""\
     <configure xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
                i18n_domain="genericsetup">
      <genericsetup:importStep
          name="name"
          title="title"
          description="description"
          handler="Products.GenericSetup.tests.test_zcml.dummy_importstep">
      </genericsetup:importStep>
     </configure>""")
     self.assertEqual(_import_step_registry.listSteps(), ['name'])
     data = _import_step_registry.getStepMetadata(u'name')
     expected = 'Products.GenericSetup.tests.test_zcml.dummy_importstep'
     self.assertEqual(data["handler"], expected)
     self.assertEqual(data["description"], u"description")
     self.assertEqual(data["title"], u"title")
     self.assertEqual(data["dependencies"], ())
     self.assertEqual(data["id"], u"name")
コード例 #27
0
    def test_install_products_which_need_the_application(self):
        self.configure(good_cfg)
        from Zope2.App import zcml
        configure_zcml = '''
        <configure
         xmlns="http://namespaces.zope.org/zope"
         xmlns:five="http://namespaces.zope.org/five"
         i18n_domain="foo">
        <include package="Products.Five" file="meta.zcml" />
        <five:registerPackage
           package="OFS.tests.applicationproduct"
           initialize="OFS.tests.applicationproduct.initialize"
           />
        </configure>'''
        zcml.load_string(configure_zcml)

        i = self.getOne()
        i.install_products()
        app = i.getApp()
        self.assertEqual(app.some_folder.meta_type, 'Folder')
コード例 #28
0
ファイル: testAppInitializer.py プロジェクト: dhavlik/Zope
    def test_install_products_which_need_the_application(self):
        self.configure(good_cfg)
        from Zope2.App import zcml
        configure_zcml = '''
        <configure
         xmlns="http://namespaces.zope.org/zope"
         xmlns:five="http://namespaces.zope.org/five"
         i18n_domain="foo">
        <include package="Products.Five" file="meta.zcml" />
        <five:registerPackage
           package="OFS.tests.applicationproduct"
           initialize="OFS.tests.applicationproduct.initialize"
           />
        </configure>'''
        zcml.load_string(configure_zcml)

        i = self.getOne()
        i.install_products()
        app = i.getApp()
        self.assertEqual(app.some_folder.meta_type, 'Folder')
コード例 #29
0
    def test_daily_job(self):
        zcml.load_string(self.zcml_template % '''
        <schedule:job
            view="dummy-view"
            unit="day"
            at="3:00"
            />
        ''')

        jobs = schedule.jobs
        self.assertEquals(len(jobs), 1)
        job = jobs[0]
        self.assertEquals(job.interval, 1)
        self.assertEquals(job.unit, 'days')
        self.assertEquals(job.at_time, datetime.time(3, 0))

        self.assertFalse(self.request.get(VIEW_MARKER))

        schedule.run_all()

        self.assertTrue(self.request.get(VIEW_MARKER))
コード例 #30
0
    def afterSetUp(self):
        self.test_folder = os.path.dirname(
                collective.amberjack.core.tests.__file__)
        archive_path = os.path.join(self.test_folder, 'basic_tours.zip')

        archive = open(archive_path, 'r')
        archive.seek(0)
        source = archive.read()
        archive.close()
        filename = os.path.basename(archive_path)
        
        zcml.load_config('meta.zcml', zope.component)
        zcml.load_config('meta.zcml', collective.amberjack.core)
        zcml.load_config('configure.zcml', collective.amberjack.core)
        zcml.load_config('configure.zcml', plone.i18n.normalizer)
        zcml.load_string('''<configure
        xmlns="http://namespaces.zope.org/zope">
        <utility component="collective.amberjack.core.blueprints.Step"
                 name="collective.amberjack.blueprints.step" />
        </configure>''')

        zcml.load_string('''<configure
        xmlns="http://namespaces.zope.org/zope">
        <utility component="collective.amberjack.core.blueprints.MicroStep"
                 name="collective.amberjack.blueprints.microstep" />
        </configure>''')

        zcml.load_string('''<configure
        xmlns="http://namespaces.zope.org/zope">
        <utility component="collective.amberjack.core.registration.FileArchiveRegistration"
                 name="zip_archive" />
        </configure>''')

        filename = os.path.dirname(collective.amberjack.core.tests.__file__)
        zcml_string = '''<configure
        xmlns="http://namespaces.zope.org/zope"
        xmlns:collective.amberjack="http://namespaces.plone.org/collective.amberjack.core">
        <collective.amberjack:tour
             tourlocation="%s/basic_tours.zip"
        />
        </configure>''' % filename
        zcml.load_string(zcml_string)
        reg = zope.component.queryUtility(ITourRegistration, 'zip_archive')
        registration = reg(source, filename)
        registration.register()
        
        self.context = self.portal
        
        manager = getUtility(ITourManager)
        manager.getTours(self.context)
コード例 #31
0
def includeDependenciesForDeferred():
    """
    Build and execute a configuration file
    to include meta, configuration and overrides
    for dependencies of the deferred development packages.
    """
    deps = getDependencyInfosForDeferred()
    config = u"""\
<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:zcml="http://namespaces.zope.org/zcml">

    """ + u"".join([
        u"""<include
        zcml:condition="not-have disable-autoinclude"
        package="%s"
        file="meta.zcml"
        />""" % name for name in deps.get('meta.zcml', ())
    ]) + """

    """ + u"".join([
        u"""<include
        zcml:condition="not-have disable-autoinclude"
        package="%s"
        file="configure.zcml"
        />""" % name for name in deps.get('configure.zcml', ())
    ]) + """

    """ + u"".join([
        u"""<includeOverrides
        zcml:condition="not-have disable-autoinclude"
        package="%s"
        file="overrides.zcml"
        />""" % name for name in deps.get('overrides.zcml', ())
    ]) + """

</configure>"""
    load_string(config)
コード例 #32
0
    def testSimilarStepsForDifferentProfilesDoNotConflict(self):
        from zope.configuration.config import ConfigurationConflictError
        try:
            zcml.load_string("""
<configure xmlns="http://namespaces.zope.org/genericsetup"
      i18n_domain="genericsetup">
 <upgradeStep
     profile="profile1"
     title="title"
     description="description"
     source="1"
     destination="2"
     handler="Products.GenericSetup.tests.test_zcml.b_dummy_upgrade" />
 <upgradeStep
     profile="profile2"
     title="title"
     description="description"
     source="1"
     destination="2"
     handler="Products.GenericSetup.tests.test_zcml.b_dummy_upgrade" />
</configure>""")
        except ConfigurationConflictError:
            self.fail('Upgrade steps should not conflict')
コード例 #33
0
    def testSimilarStepsForDifferentProfilesDoNotConflict(self):
        from zope.configuration.config import ConfigurationConflictError
        try:
            zcml.load_string("""
<configure xmlns="http://namespaces.zope.org/genericsetup"
      i18n_domain="genericsetup">
 <upgradeStep
     profile="profile1"
     title="title"
     description="description"
     source="1"
     destination="2"
     handler="Products.GenericSetup.tests.test_zcml.b_dummy_upgrade" />
 <upgradeStep
     profile="profile2"
     title="title"
     description="description"
     source="1"
     destination="2"
     handler="Products.GenericSetup.tests.test_zcml.b_dummy_upgrade" />
</configure>""")
        except ConfigurationConflictError:
            self.fail('Upgrade steps should not conflict')
コード例 #34
0
ファイル: test_guid.py プロジェクト: zenoss/zenoss-prodbin
    def afterSetUp(self):
        super(TestGuid, self).afterSetUp()

        self.ob = Identifiable('identifiable', self.dmd)
        self.dmd._setOb(self.ob.id, self.ob)
        self.aq_ob = self.dmd.identifiable
        zcml.load_string("""
        <configure xmlns="http://namespaces.zope.org/zope">
            <adapter
                for="Products.ZenUtils.guid.interfaces.IGloballyIdentifiable"
                provides="Products.ZenUtils.guid.interfaces.IGlobalIdentifier"
                factory="Products.ZenUtils.guid.guid.GlobalIdentifier"
                />
            <adapter
                for="Products.ZenUtils.tests.test_guid.Identifiable"
                provides="Products.ZenUtils.guid.interfaces.IGUIDManager"
                factory="Products.ZenUtils.guid.guid.GUIDManager"
                />
            <include package="Products.Five" file="event.zcml" />
            <subscriber handler="Products.ZenUtils.guid.event.registerGUIDToPathMapping"/>
            <subscriber handler="Products.ZenUtils.guid.event.refireEventOnObjectAddOrMove"/>
            <subscriber handler="Products.ZenUtils.guid.event.refireEventOnObjectBeforeRemove"/>
        </configure>
        """)
コード例 #35
0
ファイル: test_events.py プロジェクト: CGTIC/Plone_SP
    def setUp(self):
        self.portal = self.layer['portal']
        self.request = self.layer['request']
        self.registry = EventsRegistry

        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        name = self.portal.invokeFactory(
            id='doc1',
            title='Document 1',
            type_name='Document')

        self.document = self.portal[name]

        #
        # Subscribers
        #
        configure = """
        <configure
          xmlns="http://namespaces.zope.org/zope">

          <subscriber
            for="OFS.interfaces.ISimpleItem
                 plone.app.discussion.interfaces.IReplyAddedEvent"
            handler="plone.app.discussion.tests.test_events.reply_added"
            />

          <subscriber
            for="OFS.interfaces.ISimpleItem
                 plone.app.discussion.interfaces.IReplyRemovedEvent"
            handler="plone.app.discussion.tests.test_events.reply_removed"
            />

         </configure>
        """
        zcml.load_config("configure.zcml", Products.Five)
        zcml.load_string(configure)
コード例 #36
0
    def setUp(self):
        super(ValidationTests, self).setUp()
        self.test_folder = os.path.dirname(
                collective.amberjack.core.tests.__file__)
        archive_path = os.path.join(self.test_folder, 'basic_tours.zip')

        archive = open(archive_path, 'r')
        archive.seek(0)
        source = archive.read()
        archive.close()
        filename = os.path.basename(archive_path)

        zcml.load_config('meta.zcml', zope.component)
        zcml.load_config('configure.zcml', plone.i18n.normalizer)

        zcml.load_string('''<configure
        xmlns="http://namespaces.zope.org/zope">
        <utility component="collective.amberjack.core.blueprints.Step"
                 name="collective.amberjack.blueprints.step" />
        </configure>''')

        zcml.load_string('''<configure
        xmlns="http://namespaces.zope.org/zope">
        <utility component="collective.amberjack.core.blueprints.MicroStep"
                 name="collective.amberjack.blueprints.microstep" />
        </configure>''')

        zcml.load_string('''<configure
        xmlns="http://namespaces.zope.org/zope">
        <utility component="collective.amberjack.core.registration.FileArchiveRegistration"
                 name="zip_archive" />
        </configure>''')

        reg = queryUtility(ITourRegistration, 'zip_archive')
        registration = reg(source, filename)
        registration.register()
        self.tour = getUtility(ITourDefinition, u'01_basic_add_and_publish_a_folder-add-and-publish')

#        step = DummyStep('/')
#        self.tour.steps = [step]
#
        self.context = self.portal
コード例 #37
0
    def testCallHomeCollectorFailure(self):
        # check current version of report (should be empty)
        self.checkForExistingCallHomeData()

        # register bad acting callhome collector via zcml (or directly)
        zcml.load_string(TEST_DATA)
        zcml.load_string(SIMPLE_SUCCESS_COLLECTOR)
        zcml.load_string(FAST_FAIL_COLLECTOR)

        # call callhome scripting
        chd = CallHomeData(self.dmd, True)
        data = chd.getData()

        # make sure report has data from default collectors and
        # successful collector, but not the failing collector
        self.assertTrue(SIMPLE_SUCCESS_KEY in data)
        self.assertTrue(FAST_FAIL_KEY not in data)
        self.assertTrue("Zenoss App Data" in data)
        self.assertTrue(EXTERNAL_ERROR_KEY in data)
        self.assertEquals(FAST_FAIL_ERROR_MESSAGE,
                          data[EXTERNAL_ERROR_KEY][0]['exception'])
コード例 #38
0
    def testConstituentDataFailure(self):
        # check current version of report (should be empty?)
        self.checkForExistingCallHomeData()

        # register bad acting callhome collector via zcml (or directly)
        zcml.load_string(FAILING_TEST_DATA)
        zcml.load_string(TEST_DATA)
        zcml.load_string(SIMPLE_SUCCESS_COLLECTOR)

        # call callhome scripting
        chd = CallHomeData(self.dmd, True)
        data = chd.getData()

        # make sure report has basic values even though part failed.
        # specifically make sure that simple success section is present
        # and that the successful data entry is there and the failed
        # entry is not
        self.assertTrue("Zenoss App Data" in data)
        self.assertTrue(SIMPLE_SUCCESS_KEY in data)
        successData = data[SIMPLE_SUCCESS_KEY]
        self.assertTrue("test" in successData)
        self.assertTrue(EXTERNAL_ERROR_KEY in data)
        self.assertEquals(FAILING_DATA_ERROR_MESSAGE,
                          data[EXTERNAL_ERROR_KEY][0]['exception'])
コード例 #39
0
 def setUp(cls):
     metaconfigure.debug_mode = True
     zcml.load_string(zcml_string)
     metaconfigure.debug_mode = False
コード例 #40
0
ファイル: test_stepzcml.py プロジェクト: bendavis78/zope
 def testEmptyImport(self):
     zcml.load_string(EMPTY_ZCML)
     self.assertEqual(_import_step_registry._registered, {})
コード例 #41
0
 def testEmptyImport(self):
     zcml.load_string(EMPTY_ZCML)
     self.assertEqual(len(_import_step_registry.listSteps()), 0)
コード例 #42
0
 def setUp(cls):
     metaconfigure.debug_mode = True
     zcml.load_string(zcml_string)
     metaconfigure.debug_mode = False