0

I have a Dexterity folderish type which contains standard ATImages. I'd like it to display the first of its contained images when it is listed in a folder or collection Summary View. I tried setting an image property on the view but that wasn't even consulted when I try to access its URL: http://site/my-dex/image

That is the code I used:

class View(grok.View):
    grok.context(IMyDex)
    grok.require('zope2.View')

    @memoize
    def photos(self):
        """Return a catalog search result of photos to show
        """

        context = aq_inner(self.context)
        catalog = getToolByName(context, 'portal_catalog')
        folder_path = '/'.join(context.getPhysicalPath())
        results = catalog(path=folder_path,
                          portal_type='Image',
                          sort_on='getObjPositionInParent')
        return results

    @property
    def image(self):
        try:
            first_img = self.photos[0].getObject()
        except IndexError:
            first_img = None
        return first_img

What should I be doing instead?

Davi Lima
  • 800
  • 1
  • 6
  • 20
  • Maybe you could show your template code? – vangheem Apr 25 '12 at 15:46
  • Not a problem but I dont see how it could help since what I want is to display a canonical image for my type so it would show up in Plone's default folder_summary_view, like News item does, for instance. – Davi Lima Apr 25 '12 at 17:13

1 Answers1

1

We are doing something very similar inside collective.nitf; you can take a look at the view code.

hvelarde
  • 2,875
  • 14
  • 34