I have an issue similar to
TTW Dexterity CT - Could not adapt plone.dexterity.content.Container to interfaces.IPrimaryFieldInfo
The problem arises in a collective.cover carousel tile, when I try to add an item in compose mode. I drag an item into the tile, and it gets ignored. The strange thing is that this site, and this particular use case, has been working for about two years, and I'm not sure what might have changed.
I have traced the problem down to collective.cover.tiles.carousel.CarouselTile.populate_with_object
, where this happens:
try:
image_size = obj.restrictedTraverse('@@images').getImageSize()
except:
image_size = None
if not image_size:
return
super(CarouselTile, self).populate_with_object(obj)
At the end of this, it returns without calling super(...
, because image_size
is None
. The exception thrown is:
(Pdb) obj.restrictedTraverse('@@images').getImageSize()
*** TypeError: ('Could not adapt', <Link at blah>, <InterfaceClass plone.rfc822.interfaces.IPrimaryFieldInfo>)
getImageSize()
is in plone.namedfile.scaling.ImageScaling
:
def getImageSize(self, fieldname=None):
if fieldname is not None:
value = self.guarded_orig_image(fieldname)
return value.getImageSize()
value = IPrimaryFieldInfo(self.context).value
return value.getImageSize()
The error comes from plone.dexterity.primary.PrimaryFieldInfo.__init__
, because after it iterates through all the schemata of the context, it can't find any field that provides IPrimaryFieldInfo
.
On this site, the Link
type has these behaviors:
plone.app.dexterity.behaviors.discussion.IAllowDiscussion
plone.app.dexterity.behaviors.metadata.IDublinCore
plone.app.content.interfaces.INameFromTitle
plone.app.dexterity.behaviors.exclfromnav.IExcludeFromNavigation
plone.app.versioningbehavior.behaviors.IVersionable
plone.app.contenttypes.behaviors.leadimage.ILeadImage
plone.app.dexterity.behaviors.filename.INameFromFileName
I would have thought that ILeadImage would provide the PrimaryField. And since this used to work in the past, I can only assume that the adaptation to IPrimaryFieldInfo
used to be successful, and now it's not.
What can I do to make it so that my content returns a proper ImageSize?
(I did hack the code in collective.cover to pass it a fieldName
of image
, and that works, but with side-effects, e.g. all previous carousel images are deleted.)
These are some of the versions in use:
Plone 4.3.4.1
plone.app.contenttypes 1.1b2
collective.cover 1.0a10
plone.scale 1.3.4
plone.namedfile 2.0.7
plone.dexterity 2.2.4