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

Using Dexterity for Plone Site #2454

Open
jaroel opened this Issue Jun 24, 2018 · 14 comments

Comments

8 participants
@jaroel
Member

jaroel commented Jun 24, 2018

PLIP (Plone Improvement Proposal)

Responsible Persons

Proposer: Roel Bruggink

Seconder:

Abstract

Replace the CMFPlone Portal class with a Dexterity implementation.

Motivation

Moving from a CMF item to a Dexterity container will allow us to edit the site root directly using the DX framework including support for behaviors.

This makes it possible to add the rich text behavior to the site root. This way we don’t need to use extra documents to select as default views. This is the last step we need to be able to go with a full folderish objects site and get rid of the “select item as default view” which is a huge usability improvement

Assumptions

Proposal & Implementation

Replace the base class for Products.CMFPlone.Portal.PloneSite with a DX container.
Development is initially done on the latest stable (5.1) branch of Products.CMFPlone. We'll move to unstable (5.2) when this is done or if 5.2 is released, whichever is earlier.

Deliverables

PLIP buildout config can be found here: https://github.com/plone/buildout.coredev/blob/5.1/plips/plip-2454-dx-siteroot.cfg

Change Products.CMFPlone.Portal.PloneSite from CMF to DX. #2453
Various supportive changes in -at least- plone/plone.app.contenttypes#475 and plone/plone.dexterity#85.

Risks

Currently unknown.

Participants

Roel Bruggink

@jensens

This comment has been minimized.

Member

jensens commented Jun 25, 2018

How do you plan to migrate the Site Root?

@jaroel

This comment has been minimized.

Member

jaroel commented Jun 25, 2018

I haven't given it too much thought atm.
I copied over an existing Plone 5.1 Data.fs into my development stuff and at least it loaded the state correctly from the ZODB, had the correct mro for the Plone Site root and rendered the site just fine.

Something like this should do using a view/script on the zope root for each Plone site:

class MigrateRootToDx(BrowserView):

    def __call__(self):
        from Acquisition import aq_base
        from plone.protect.auto import safeWrite
        request = self.request

        print("Start migration Plone Sites root to DX")
        for site in self.context.objectValues('Plone Site'):
            safeWrite(site, request)
            print("Running for {}".format(site))

            # Initialise the btree.
            if '_tree' not in site.__dict__:
                print("Initialising btrees")
                site._initBTrees()

            # Migrate existing portal content.
            print("Migrate content")
            for obj_meta in site._objects:
                obj_id = obj_meta['id']
                print("Migrating object {}".format(obj_id))
                # Load the content item, tool, or whatever
                obj = getattr(site, obj_id)
                # insert it into the btree.
                # Use _setOb so we don't reindex stuff. the paths stay the same.
                site._setOb(obj_id, aq_base(obj))
                # Drop the attribute
                del site.__dict__[obj_id]

            # Drop no-longer needed bookkeeping
            print("Clean up bookkeeping data")
            del site.__dict__['_objects']
            site._p_changed = True

I do need to check what bookkeeping can be dropped.

edit: I've just tested the above and that seems to Just Works (tm).

>>> sorted(app.Plone.keys())
['_Access_arbitrary_user_session_data_Permission', '_Access_contents_information_Permission', '_Access_inactive_portal_content_Permission', '_Access_session_data_Permission', '_Add_portal_content_Permission', '_Add_portal_folders_Permission', '_Add_portal_member_Permission', '_Allow_sendto_Permission', '_CMFEditions__Access_previous_versions_Permission', '_CMFEditions__Apply_version_control_Permission', '_CMFEditions__Checkout_to_location_Permission', '_CMFEditions__Revert_to_previous_versions_Permission', '_CMFEditions__Save_new_version_Permission', '_Change_local_roles_Permission', '_Content_rules__Manage_rules_Permission', '_Copy_or_Move_Permission', '_Delete_comments_Permission', '_Delete_objects_Permission', '_Delete_own_comments_Permission', '_Edit_comments_Permission', '_FTP_access_Permission', '_List_folder_contents_Permission', '_List_portal_members_Permission', '_List_undoable_changes_Permission', '_Mail_forgotten_password_Permission', '_Manage_properties_Permission', '_Modify_portal_content_Permission', '_Modify_view_template_Permission', '_Portlets__Manage_own_portlets_Permission', '_Portlets__Manage_portlets_Permission', '_Portlets__View_dashboard_Permission', '_Reply_to_item_Permission', '_Request_review_Permission', '_Review_comments_Permission', '_Review_portal_content_Permission', '_Search_ZCatalog_Permission', '_Set_own_password_Permission', '_Set_own_properties_Permission', '_Show_Toolbar_Permission', '_Undo_changes_Permission', '_Use_Database_Methods_Permission', '_Use_external_editor_Permission', '_Use_mailhost_services_Permission', '_Use_version_control_Permission', '_View_Groups_Permission', '_View_History_Permission', '_View_Permission', '_View_management_screens_Permission', '_WebDAV_Lock_items_Permission', '_WebDAV_Unlock_items_Permission', '_WebDAV_access_Permission', '__ZCacheManager_ids__', '__ac_local_roles__', '__ac_roles__', '__allow_groups__', '__annotations__', '__before_publishing_traverse__', '__before_traverse__', '__error_log__', '_components', '_count', '_mt_index', '_owner', '_plone_app_contenttypes__Add_Collection_Permission', '_plone_app_contenttypes__Add_Document_Permission', '_plone_app_contenttypes__Add_Event_Permission', '_plone_app_contenttypes__Add_File_Permission', '_plone_app_contenttypes__Add_Folder_Permission', '_plone_app_contenttypes__Add_Image_Permission', '_plone_app_contenttypes__Add_Link_Permission', '_plone_app_contenttypes__Add_News_Item_Permission', '_plone_app_event__Import_Ical_Permission', '_plone_app_multilingual__Manage_Translations_Permission', '_plone_resource__Export_ZIP_file_Permission', '_plone_resourceeditor__Manage_Sources_Permission', '_properties', '_tree', '_v__providedBy__', 'cmf_uid', 'contributors', 'creation_date', 'creators', 'default_page', 'description', 'effective_date', 'expiration_date', 'format', 'id', 'language', 'modification_date', 'rights', 'subject', 'title']

>>> app.Plone.portal_catalog
<CatalogTool at /Plone/portal_catalog>

>>> app.Plone.portal_catalog()
[<Products.ZCatalog.Catalog.mybrains object at 0x10b27e598>, <Products.ZCatalog.Catalog.mybrains object at 0x10b27e0b8>, <Products.ZCatalog.Catalog.mybrains object at 0x10b258668>, <Products.ZCatalog.Catalog.mybrains object at 0x10b258940>, <Products.ZCatalog.Catalog.mybrains object at 0x10b258bb0>]

>>> app.Plone.portal_catalog()[0]
<Products.ZCatalog.Catalog.mybrains object at 0x10b258328>

>>> app.Plone.portal_catalog()[0].getObject()
<Document at /Plone/front-page>

>>> 'portal_catalog' in app.Plone.__dict__
False
@jaroel

This comment has been minimized.

Member

jaroel commented Jun 25, 2018

We'll need to add the Plone Site FTI and fix the edit method alias when upgrading.
Need to check plone.app.multilingual as we won't have a front-page object anymore.

@jensens jensens added this to New (drafts) in PLIPs Jun 26, 2018

@ebrehault

This comment has been minimized.

Member

ebrehault commented Jun 26, 2018

@jaroel The FWT is very positive about this PLIP.

It would be useful to get more information about the motivations (what could be the benefits? What kind of behaviors could be usefully used on the Plone Site object) as it would help to communicate about this important improvement.

Note: we will vote on the PLIP during our next meeting.

@sunew

This comment has been minimized.

Contributor

sunew commented Jun 26, 2018

for one, selectablecontrainstypes behavior would be super useful:)

@robgietema

This comment has been minimized.

Member

robgietema commented Jul 2, 2018

This makes it possible to add the rich text behavior to the site root. This way we don’t need to use extra documents to select as default views. This is the last step we need to be able to go with a full folderish objects site and get rid of the “select item as default view” which is a huge usability improvement. I can second this proposal.

@ebrehault

This comment has been minimized.

Member

ebrehault commented Jul 10, 2018

@jaroel, the @plone/framework-team approved this PLIP

@gforcada gforcada moved this from New (drafts) to In Process (approved) in PLIPs Jul 10, 2018

@jaroel

This comment has been minimized.

Member

jaroel commented Jul 10, 2018

@ebrehault that's great news, thanks!

@tkimnguyen

This comment has been minimized.

Member

tkimnguyen commented Jul 11, 2018

How does this work? "This is the last step we need to be able to go with a full folderish objects site and get rid of the 'select item as default view'" In CastleCMS we got rid of default items by using Mosaic and including a rich text tile on the Folder content type default layout

@tisto

This comment has been minimized.

Member

tisto commented Aug 7, 2018

@jaroel would you mind giving us an update on the current status? What is missing before we can review your code? Do you plan to integrate this in Plone 5.2 or later?

@tisto

This comment has been minimized.

Member

tisto commented Aug 7, 2018

@tkimnguyen in Plone-React we got rid of default items as well. The new tiles-based "Page" type is folderish by default as well.

@pbauer

This comment has been minimized.

@jaroel

This comment has been minimized.

Member

jaroel commented Aug 8, 2018

@tisto In practice it seems to work just fine. I'm resolving the test failures when I have time.
See https://jenkins.plone.org/view/PLIPs/job/plip-dx-siteroot/ for the current state.

You can check the changes done so far using the PLIP buildout config https://github.com/plone/buildout.coredev/blob/5.1/plips/plip-2454-dx-siteroot.cfg .

I wouldn't see this as a blocker for 5.2. I'd not even consider this for 5.2, unless people have used this in production somewhere.

@jaroel

This comment has been minimized.

Member

jaroel commented Aug 19, 2018

@gforcada or @tisto I'm getting timeout accessing the ftp server on jenkins (https://jenkins.plone.org/view/PLIPs/job/plip-dx-siteroot/12/testReport/plone.app/testing/layers_rst/)
Any idea what could be going on there?

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