Ticket #14121 (new Bug)

Opened 23 months ago

Last modified 23 months ago

How to make dexterity modifications available to other clients?

Reported by: mekell Owned by: davisagli
Priority: critical Milestone: 4.x
Component: Dexterity Version: 4.3
Keywords: dexterity Cc:

Description

The modified model_source of a dexterity type is not available for other clients until the other client restarts.

Invalidating or clearing the SCHEMA_CACHE is not a working solution: every client seems to have its own SCHEMA_CACHE which afik cannot be cleared or invalidated from another client.

The scenario presented here uses ipython as second client. The same can be reproduced through the web by starting two clients: (1) create a dexterity type in client1, and (2) edit the XML Field Model in client2.

utils.sync()
from Products.CMFCore.utils import getToolByName
from plone.dexterity.fti import DexterityFTI
id = 'mydexteritytype'
plone_site = app.Plone
tool_portal_types = getToolByName(plone_site, 'portal_types')
if tool_portal_types.hasObject(id): tool_portal_types.manage_delObjects(id)
utils.commit()
utils.sync()
fti = DexterityFTI(id)
fti.id = id
data = {}
data['title'] = id
data['i18n_domain'] = 'plone'
data['behaviors'] = "\n".join([
            'plone.app.dexterity.behaviors.metadata.IDublinCore',
            'plone.app.content.interfaces.INameFromTitle',
            ])
data['model_source'] = '''
<model xmlns:security="http://namespaces.plone.org/supermodel/security"
       xmlns:marshal="http://namespaces.plone.org/supermodel/marshal"
       xmlns:form="http://namespaces.plone.org/supermodel/form"
       xmlns="http://namespaces.plone.org/supermodel/schema">
    <schema>
        <field name="original" type="zope.schema.TextLine">
            <default>original</default>
            <description/>
            <title>original</title>
        </field>
    </schema>
</model>'''
data['klass'] = 'plone.dexterity.content.Container'
data['filter_content_types'] = True
data['icon_expr'] = 'string:${portal_url}/document_icon.png'
fti.manage_changeProperties(**data)
tool_portal_types._setObject(fti.id, fti)
utils.commit()

After running the code above, the new created mydexteritytype is available for all other clients.

The modifications produced by the following code will be only available in the client running the code. All other clients are not aware of the changes.

utils.sync()
from plone.dexterity.interfaces import IDexterityFTI
from zope.component import getUtility
fti = getUtility(IDexterityFTI, name=id)
model_source = '''
<model xmlns:security="http://namespaces.plone.org/supermodel/security"
       xmlns:marshal="http://namespaces.plone.org/supermodel/marshal"
       xmlns:form="http://namespaces.plone.org/supermodel/form"
       xmlns="http://namespaces.plone.org/supermodel/schema">
    <schema>
        <field name="modified" type="zope.schema.TextLine">
            <default>modified</default>
            <description/>
            <title>modified</title>
        </field>
    </schema>
</model>'''
fti.manage_changeProperties(model_source=model_source)
from plone.dexterity.schema import SCHEMA_CACHE
SCHEMA_CACHE.invalidate(fti)
SCHEMA_CACHE.clear()
utils.commit()

Change History

comment:1 Changed 23 months ago by mekell

  • Priority changed from minor to critical
  • Owner set to davisagli
  • Component changed from Unknown to Dexterity
Note: See TracTickets for help on using tickets.