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

Component conversation_view not available when executing view export_content() from the Plone CLI #92

Open
Rudd-O opened this issue Dec 26, 2021 · 9 comments

Comments

@Rudd-O
Copy link
Contributor

Rudd-O commented Dec 26, 2021

I hae a snippet of code that is supposed to export (and it works with all exports other than content), but when I try it with content export, I get a zero-bytes JSON file. This snippet of code runs as an entry point of my bin/client program.

Does anyone know what the problem with the export is?

Code: https://gist.github.com/Rudd-O/f46154c80eb9937ec387e2b460ebbe8b

EDIT:

Ultimately the goal is to be able to command an export of everything via the Plone CLI (bin/client -c export.py), primarily for (but not limited to) migration automation and testing. All other exports work correctly using this code — only the content one does not.

@Rudd-O
Copy link
Contributor Author

Rudd-O commented Dec 26, 2021

Related: #93

@Rudd-O
Copy link
Contributor Author

Rudd-O commented Dec 26, 2021

Aha:

ERROR:collective.exportimport.export_content:Error exporting http:https://nohost/manuelamador.name/manuel-amador-lebenslauf
Traceback (most recent call last):
  File "/home/user/optplone/deployments/master/src/collective.exportimport/src/collective/exportimport/export_content.py", line 281, in export_content
    item = serializer()
  File "/home/user/optplone/buildout-cache/eggs/cp38/plone.restapi-6.15.0-py3.8.egg/plone/restapi/serializer/dxcontent.py", line 107, in __call__
    result["allow_discussion"] = getMultiAdapter(
  File "/home/user/optplone/buildout-cache/eggs/cp38/zope.component-4.6.2-py3.8.egg/zope/component/_api.py", line 104, in getMultiAdapter
    raise ComponentLookupError(objects, interface, name)
zope.interface.interfaces.ComponentLookupError: ((<Document at /manuelamador.name/manuel-amador-lebenslauf>, <HTTPRequest, URL=http:https://nohost>), <InterfaceClass zope.interface.Interface>, 'conversation_view')

All of my content objects raise ComponentLookupError when exported via the CLI. This does not arise when exporting via the Web interface by point and click.

What gives? Is my REQUEST object not valid or something?

@Rudd-O
Copy link
Contributor Author

Rudd-O commented Dec 26, 2021

The snippet of code in dxcontent.py that specifically causes this:

        result["allow_discussion"] = getMultiAdapter(
            (self.context, self.request), name="conversation_view"
        ).enabled()

Why is the conversation view not registered for my Dexterity content? This happens for all my sites, even freshly-created ones. I have to conclude there is something about running from the Plone debug CLI that causes this. How can I trace the situation to the problem? Thanks in advance.

@Rudd-O
Copy link
Contributor Author

Rudd-O commented Dec 26, 2021

By the way, the export from CLI problem happens in both Plone 5.x and Plone 6.

@Rudd-O
Copy link
Contributor Author

Rudd-O commented Dec 26, 2021

Note that I have verified that the configure.zcml from plone.app.discussion.browser that registers the conversation_view is in fact loaded during the client script startup (I broke it intentionally and saw it fail to start).

@Rudd-O
Copy link
Contributor Author

Rudd-O commented Dec 26, 2021

OK.

Using the CLI:

(<FolderishDocument at /manuelamador.name/manuel-amador-lebenslauf>, <HTTPRequest, URL=http:https://nohost>) [classImplements(?), directlyProvides(HTTPRequest, IDefaultBrowserLayer, IPathBlobsMarker, IMigrationMarker, IRawRichTextMarker, classImplements(HTTPRequest, IBrowserRequest, IAttributeAnnotatable))]
ERROR:collective.exportimport.export_content:Error exporting http:https://nohost/manuelamador.name/manuel-amador-lebenslauf
Traceback (most recent call last):
  File "/home/user/optplone/deployments/601a/src/collective.exportimport/src/collective/exportimport/export_content.py", line 280, in export_content
    item = serializer(include_items=False)
  File "/home/user/optplone/buildout-cache/eggs/cp38/plone.restapi-8.16.2-py3.8.egg/plone/restapi/serializer/dxcontent.py", line 150, in __call__
    folder_metadata = super().__call__(version=version)
  File "/home/user/optplone/buildout-cache/eggs/cp38/plone.restapi-8.16.2-py3.8.egg/plone/restapi/serializer/dxcontent.py", line 111, in __call__
    result["allow_discussion"] = getMultiAdapter(
  File "/home/user/optplone/buildout-cache/eggs/cp38/zope.component-4.6.2-py3.8.egg/zope/component/_api.py", line 104, in getMultiAdapter
    raise ComponentLookupError(objects, interface, name)
zope.interface.interfaces.ComponentLookupError: ((<FolderishDocument at /manuelamador.name/manuel-amador-lebenslauf>, <HTTPRequest, URL=http:https://nohost>), <InterfaceClass zope.interface.Interface>, 'conversation_view')

Using the Web UI:

(<FolderishDocument at /manuelamador.name/manuel-amador-lebenslauf>, <WSGIRequest, URL=http:https://127.0.1.4:8080/manuelamador.name/@@export_content>) [classImplements(?), directlyProvides(WSGIRequest, IPloneFormLayer, IDiscussionLayer, IThemingLayer, IBrowserLayer, IPloneAppContenttypesLayer, IThemeSpecific, collective.folderishtypes.dx.interfaces.IThemeSpecific, IManuelAmadorPolicyLayer, IDefaultBrowserLayer, IPathBlobsMarker, IMigrationMarker, IRawRichTextMarker)]

The differences are stark in what interfaces are provided by the object when requested via the CLI, vs. when requested via the Web UI.

Why!?

@Rudd-O
Copy link
Contributor Author

Rudd-O commented Dec 26, 2021

Uh there's also no difference what request I use (tried both makerequest and a hack to use WSGIRequest).

Is there some special initialization I need to be doing right before I call the export_content() view? Thanks in advance.

@Rudd-O Rudd-O changed the title Export from command line does not work Component conversation_view not available when executing view export_content() from the Plone CLI Dec 26, 2021
@Rudd-O
Copy link
Contributor Author

Rudd-O commented Dec 26, 2021

Could it be that the call to setDefaultSkin during Zope startup (executed during do_run() by plone.recipe.zope2instance.ctl)is not actually including the correct skins? I tried adding option no_request to it, and it seems like it worked to not add the REQUEST object to the app, but ...

@Rudd-O
Copy link
Contributor Author

Rudd-O commented Dec 26, 2021

Updated gist of code: https://gist.github.com/Rudd-O/4e657a90b8bc405de08d143221cee5ac (the part where "content" is skipped should be removed).

To be run using bin/client --no-request -c export_content.py site_id /path/to/export.

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

No branches or pull requests

1 participant