Is it possible to create a Plone site through the web that is not on the Zope root? In 6.0, before plone.distribution, I could hack this by changing the form action, but even this workaround isn't possible with the new React form.
For some background, in our configuration, we have ~10 sites on individual dbs that are mounted onto a main db, so they run under one WSGI process. This seems to not be popular anymore, and has uncovered some bugs in systems that don't support it (RelatedItems widget (classic) broken if site not on the Zope root · Issue #4202 · plone/Products.CMFPlone · GitHub) but we built this infrastructure over 15 years ago and moving the site path has proved to be problematic with regard to zope intids and relations, at the very least.
Anyway, the "ploneAddSite" view requires interface OFS.interfaces.IApplication which is not provided by Folders. I tried changing the ZCML to have it support any interface, but get a 404.. Side note: @sites returns a 404 for me in Postman on a Folder, even though it looks like the ZCML should support it.
In trying to develop changes to have this work on folders, I am stymied by the inability to get @sites from a Folder. It looks like this should already be supported. Even if I change the for= in the zcml to simply * it returns a 404 on GET. Does anyone have suggestions on having this work on folders, or how to debug this?
To make @sites, respectively @@ploneAddSite work, might need some more work.
See ploneAddSite
if not name.startswith("@"):
return super().publishTraverse(request, name)
It raises NotFound if not called on the zope root.
Update:
I quickly registered the traverser for everything:
@adapter(Interface, IRequest)
class RestTraverser(AppTraverser):
....
Along with registering those API endpoints to * as well, I was also able to create a new site in my mount point .
Not sure about the implications of this code running for every request. I would advise not to do so.
Best solution probably is to mark MountPoint objects with an interface and register the RestTraverser specifically for those objects as well. Along with those zcml tweaks.
Thanks for looking into this. I also got this to work by replacing IApplication with OFS.interfaces.IFolder for the adapter and the two views. IApplication inherits IFolder, so root still works. (edit: PloneSite also inherits IFolder, so it does mean it is called more than it needs to be)
This would be good to have an answer to. Even if, in the extreme case, Plone decides to not support mounted DBs anymore, it would still need to be supported in plone.distribution in order to move that data to another db.
Can you confirm, in Classic UI, that the Link object display the correct link for Plone sites not in the root? Time ago I've found code that used the catalog and the link for an object was displayed as /Plone/... and the code used acquisition to make things work. It should be fixed now as you can see in demo (an example created just now https://classic.demo.plone.org/en/demo/test-link), but I didn't test Plone sites not in root.