Skip to content

Cannot export content from LIF where language is None #95

Description

@pbauer

Exporting a site with content in the LIF ("en/assets") like classic.demo.plone.org fails with:

  File "/Users/pbauer/workspace/demo.plone.org/classic/./bin/export-distribution", line 10, in <module>
    sys.exit(export())
             ^^^^^^^^
  File "/Users/pbauer/workspace/demo.plone.org/classic/lib/python3.12/site-packages/plone/distribution/cli/__init__.py", line 49, in export
    results = get_exporter(site).export_site(path, options=namespace)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pbauer/workspace/demo.plone.org/classic/lib/python3.12/site-packages/plone/exportimport/exporters/__init__.py", line 72, in export_site
    new_paths = exporter.export_data(path, options=options)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pbauer/workspace/demo.plone.org/classic/lib/python3.12/site-packages/plone/exportimport/exporters/content.py", line 163, in export_data
    return super().export_data(base_path, data_hooks, obj_hooks, options=options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pbauer/workspace/demo.plone.org/classic/lib/python3.12/site-packages/plone/exportimport/exporters/base.py", line 77, in export_data
    paths = self.dump()
            ^^^^^^^^^^^
  File "/Users/pbauer/workspace/demo.plone.org/classic/lib/python3.12/site-packages/plone/exportimport/exporters/content.py", line 138, in dump
    path = self.dump_one(obj)
           ^^^^^^^^^^^^^^^^^^
  File "/Users/pbauer/workspace/demo.plone.org/classic/lib/python3.12/site-packages/plone/exportimport/exporters/content.py", line 119, in dump_one
    data = self.serialize(obj)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/pbauer/workspace/demo.plone.org/classic/lib/python3.12/site-packages/plone/exportimport/exporters/content.py", line 89, in serialize
    data = fixer.func(data, obj, config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pbauer/workspace/demo.plone.org/classic/lib/python3.12/site-packages/plone/exportimport/utils/content/export_helpers.py", line 133, in fix_language
    token = item.get("language", {}).get("token", placeholder)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'

So "language": null, needs to be ok during export. Fixing a missing language is a task that the import (not the export) should handle (depending on the language of the parent).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions