I was working on Products.BlobNewsItem before the weekend as I was bumping into strange issues that made the image blob field not display on editing and viewing of the newsitem content type.
After some back and forth, looking around I found a pretty decent solution to the issue.. after putting some print statements in Archetypes I found that the field wasn't writeable, and looking further down, the accessor and mutator properties and methods weren't being set for the ImageField.
Well, I put this code in there:
class MyBlob:
\tsecurity = ClassSecurityInfo()
\tsecurity.declareProtected(ModifyPortalContent, 'setImage')
\tdef setImage(self, *arguments, **keywords):
\t\tfield = self.getField('image')
\t\tfield.set(self, *arguments, **keywords)
\tsecurity.declareProtected(ModifyPortalContent, 'getImage')
\tdef getImage(self, *arguments, **keywords):
\t\tfield = self.getField('image')
\t\treturn field.get(self, *arguments, **keywords)
newsitem.ATNewsItem.security = MyBlob.security
newsitem.ATNewsItem.setImage = MyBlob.setImage.im_func
newsitem.ATNewsItem.getImage = MyBlob.getImage.im_func
InitializeClass(newsitem.ATNewsItem)
as well as
\t\t\t\tmutator='setImage',
\t\t\t\taccessor='getImage',
in the ImageField and that does the trick. Why this issue popped up I don't know, but at least there's a pretty easy way to fix it.
After some back and forth, looking around I found a pretty decent solution to the issue.. after putting some print statements in Archetypes I found that the field wasn't writeable, and looking further down, the accessor and mutator properties and methods weren't being set for the ImageField.
Well, I put this code in there:
class MyBlob:
\tsecurity = ClassSecurityInfo()
\tsecurity.declareProtected(ModifyPortalContent, 'setImage')
\tdef setImage(self, *arguments, **keywords):
\t\tfield = self.getField('image')
\t\tfield.set(self, *arguments, **keywords)
\tsecurity.declareProtected(ModifyPortalContent, 'getImage')
\tdef getImage(self, *arguments, **keywords):
\t\tfield = self.getField('image')
\t\treturn field.get(self, *arguments, **keywords)
newsitem.ATNewsItem.security = MyBlob.security
newsitem.ATNewsItem.setImage = MyBlob.setImage.im_func
newsitem.ATNewsItem.getImage = MyBlob.getImage.im_func
InitializeClass(newsitem.ATNewsItem)
as well as
\t\t\t\tmutator='setImage',
\t\t\t\taccessor='getImage',
in the ImageField and that does the trick. Why this issue popped up I don't know, but at least there's a pretty easy way to fix it.