Skip to content
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

Should plone.app.contenttypes.browser.folder.FolderView.has_image check if img is callable? #426

Closed
idgserpro opened this issue Sep 18, 2017 · 1 comment

Comments

@idgserpro
Copy link

In

https://github.com/plone/plone.app.contenttypes/blob/1.1.1/plone/app/contenttypes/browser/folder.py#L166

It only checks if there's an attr named image to state that an object has an image, but that's not always the case if a content type defined image as a method instead of an attribute, like we have in

https://github.com/collective/collective.nitf/blob/d9367c479d9112b17690b18d3143c3f6b4c599fa/src/collective/nitf/content.py#L32

In this situation, it always returns True since it's a <bound method NITF.image of <NITF at.

A fix would be to add a condition asking if img is callable, call it, and check it's value as well. For example:

if callable(img):
    img = getattr(obj, 'image', None)
    img = img()

It would be nice if this was backported to plone.app.contenttypes 1.1.x as well, since it's still used in Plone 4.

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

No branches or pull requests

2 participants