Hello everyone,
I created a custom dexterity field that is called from my IDataManager
adapter.
Inside the field setter I noted, that the object being created is an Acquisition.ImplicitAcquisitionWrapper
object that fails when calling content.UID()
.
Code excerpt from plone.dexterity.browser.add
:
def create(self, data):
fti = getUtility(IDexterityFTI, name=self.portal_type)
content = createObject(fti.factory)
# Note: The factory may have done this already, but we want to be sure
# that the created type has the right portal type. It is possible
# to re-define a type through the web that uses the factory from an
# existing type, but wants a unique portal_type!
if hasattr(content, '_setPortalTypeName'):
content._setPortalTypeName(fti.getId())
# Acquisition wrap temporarily to satisfy things like vocabularies
# depending on tools
if IAcquirer.providedBy(content):
content = content.__of__(self.container)
_applyChanges(self, content, data, force=True)
for group in self.groups:
_applyChanges(group, content, data, force=True)
---> import pdb; pdb.set_trace()
return aq_base(content)
PDB Session:
(Pdb++) content
*** TypeError: descriptor '__repr__' for 'persistent.Persistent' objects doesn't apply to 'Acquisition.ImplicitAcquisitionWrapper' object
(Pdb++) aq_base(content)
<content.object.Object object at 0x1212d1750>
(Pdb++) aq_base(content).UID()
*** TypeError: ('Could not adapt', <content.object.Object object at 0x1212d1750>, <InterfaceClass plone.uuid.interfaces.IUUID>)
(Pdb++) content.UID()
2021-10-29 12:21:33 ERROR Zope.SiteErrorLog 1635502893.580.103694563934 http://localhost:8080/senaite/clients/client-1/++add++Object
Traceback (innermost last):
Module ZServer.ZPublisher.Publish, line 144, in publish
Module ZPublisher.mapply, line 85, in mapply
Module ZServer.ZPublisher.Publish, line 44, in call_object
Module plone.z3cform.layout, line 63, in __call__
Module plone.z3cform.layout, line 47, in update
Module plone.dexterity.browser.add, line 143, in update
Module plone.z3cform.fieldsets.extensible, line 65, in update
Module plone.z3cform.patch, line 30, in GroupForm_update
Module z3c.form.group, line 145, in update
Module plone.app.z3cform.csrf, line 22, in execute
Module z3c.form.action, line 98, in execute
Module z3c.form.button, line 315, in __call__
Module z3c.form.button, line 170, in __call__
Module plone.dexterity.browser.add, line 118, in handleAdd
Module z3c.form.form, line 263, in createAndAdd
Module plone.dexterity.browser.add, line 88, in create
Module plone.dexterity.browser.add, line 88, in create
Module bdb, line 49, in trace_dispatch
Module bdb, line 67, in dispatch_line
Module pdb, line 158, in user_line
Module pdb, line 233, in interaction
Module cmd, line 142, in cmdloop
Module pdb, line 279, in onecmd
Module cmd, line 220, in onecmd
Module pdb, line 516, in default
Module pdb, line 244, in default
Module OFS.SimpleItem, line 87, in __repr__
TypeError: descriptor '__repr__' for 'persistent.Persistent' objects doesn't apply to 'Acquisition.ImplicitAcquisitionWrapper' object
My question now:
Can I access the UID from a dexterity field, or do I have to do this code in an IObjectCreated
event handler?
Thanks as always for your feedback
Ramon