Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plone.app.registry XML export can not handle dict-ish data #2980

Open
zopyx opened this issue Nov 12, 2019 · 1 comment
Open

plone.app.registry XML export can not handle dict-ish data #2980

zopyx opened this issue Nov 12, 2019 · 1 comment

Comments

@zopyx
Copy link
Member

zopyx commented Nov 12, 2019

Plone 5.2

The XML registry export does not work with a dict-ish schema as attached.

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 155, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 337, in publish_module
  Module ZPublisher.WSGIPublisher, line 255, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 61, in call_object
  Module plone.app.registry.browser.exportxml, line 34, in __call__
  Module plone.app.registry.browser.exportxml, line 96, in export
  Module lxml.etree, line 1018, in lxml.etree._Element.text.__set__
  Module lxml.etree, line 710, in lxml.etree._setNodeText
  Module lxml.etree, line 698, in lxml.etree._createTextNode
  Module lxml.etree, line 1491, in lxml.etree._utf8
TypeError: Argument must be bytes or unicode, got 'dict'


# noqa: D100

from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper
from plone.autoform import directives
from ugent.registry import DictListRegistryEditForm
from z3c.form.browser.multi import MultiWidget
from zope.interface import Interface
from zope.schema import Dict
from zope.schema import List
from zope.schema import TextLine

from ..config import message_factory as _


class IAuthorshipSettings(Interface):
    """Authorship settings.
    """

    directives.widget("departments", MultiWidget)
    departments = List(
        title=_("Departments"),
        value_type=Dict(
            title=_("Department"),
            key_type=TextLine(title=_("Key")),
            value_type=TextLine(title=_("Value")),
        ),
        required=False,
    )

    directives.widget("subdepartments", MultiWidget)
    subdepartments = List(
        title=_("Subdepartments"),
        value_type=Dict(
            title=_("Subdepartment"),
            key_type=TextLine(title=_("Key")),
            value_type=TextLine(title=_("Value")),
        ),
        required=False,
    )


class AuthorshipControlPanelForm(DictListRegistryEditForm):
    """Control panel form for authorship.
    """

    schema = IAuthorshipSettings

    label = "Authorship Settings"
    description = "Authorship settings."

    dictlists = (
        (
            "departments",
            (
                "department",
                "name",
                "coordinators",
                "backups",
            ),
        ),
        (
            "subdepartments",
            (
                "department",
                "subdepartment",
                "name",
                "providers",
                "editors",
            ),
        ),
    )


class AuthorshipControlPanel(ControlPanelFormWrapper):
    """Control panel for authorship.
    """

    form = AuthorshipControlPanelForm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants