Example #1
0
    def test_export_with_dict(self):

        xml = """\
<registry>
  <record name="test.export.dict">
    <field type="plone.registry.field.Dict">
      <default />
      <key_type type="plone.registry.field.ASCIILine">
        <title>Key</title>
      </key_type>
      <title>Dict</title>
      <value_type type="plone.registry.field.Int">
        <title>Value</title>
      </value_type>
    </field>
    <value>
      <element key="a">1</element>
    </value>
  </record>
</registry>"""

        self.registry.records['test.export.dict'] = \
            Record(field.Dict(title=u"Dict", default={},
                              key_type=field.ASCIILine(title=u"Key"),
                              value_type=field.Int(title=u"Value")),
                   value={'a': 1})

        context = DummyExportContext(self.site)
        exportRegistry(context)

        self.assertEqual('registry.xml', context._wrote[0][0])
        self.assertXmlEquals(xml, context._wrote[0][1])
Example #2
0
    def test_import_dict_nopurge(self):
        xml = """\
<registry>
    <record name="test.registry.field">
        <value purge="false">
            <element key="x">4</element>
            <element key="y">6</element>
        </value>
    </record>
</registry>
"""

        self.registry.records['test.registry.field'] = \
            Record(field.Dict(title=u"Simple record",
                              key_type=field.ASCIILine(title=u"Key"),
                              value_type=field.Int(title=u"Val")),
                   value={'a': 1})

        context = DummyImportContext(self.site, purge=False)
        context._files = {'registry.xml': xml}

        importRegistry(context)

        self.assertEquals(1, len(self.registry.records))
        self.failUnless(
            isinstance(self.registry.records['test.registry.field'].field,
                       field.Dict))
        self.assertEquals(
            u"Simple record",
            self.registry.records['test.registry.field'].field.title)
        self.assertEquals({
            'a': 1,
            'x': 4,
            'y': 6
        }, self.registry['test.registry.field'])
Example #3
0
    def test_provider_without_url(self):
        """Deal with a provider set without an url template"""
        from plone.registry import field
        from plone.registry.record import Record

        reg = self.reg
        value = {u"url": u"", u"logo": u"", u"id": u"foo"}
        record = Record(field.Dict(title=u"Foo"), value)
        reg.records["sc.social.bookmarks.providers.foo"] = record
        self.set_up_social_bookmarks(providers=("foo", ))
        viewlet = SocialBookmarksViewlet(self.page, self.request, None)
        viewlet.update()
        html = viewlet.render()
        self.assertFalse("foo" in html)
Example #4
0
class IGeoVocabularies(Interface):
    geotags = field.Dict(
        title=_(u'Geotags tree'),
        key_type=field.TextLine(),
        value_type=field.Dict(
            key_type=field.TextLine(),
            value_type=field.TextLine(),
        ),
    )

    biotags = field.Dict(
        title=_(u'Biogeographical regions'),
        key_type=field.TextLine(),
        value_type=field.Dict(
            key_type=field.TextLine(),
            value_type=field.TextLine(),
        ),
    )

    countries_mapping = field.Dict(
        title=_(u'EEA Custom Country Name Mappings'),
        key_type=field.TextLine(),
        value_type=field.TextLine(),
    )