2012-04-25 39 views
0

我有一个敏捷的文件夹类型,其中包含标准的ATImages。当它列在文件夹或集合摘要视图中时,我希望它显示其包含的第一个图像。我试图在视图设置图像属性,但,当我试图访问其URL甚至没有咨询:http://site/my-dex/image敏捷图像摘要视图

的代码中,我使用的:

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 

,我应该怎么做呢?

+0

也许你可以显示你的模板代码? – vangheem 2012-04-25 15:46:59

+0

没有问题,但我没有看到它是如何帮助的,因为我想要显示我的类型的规范图像,所以它会出现在Plone的默认folder_summary_view中,例如新闻项目。 – 2012-04-25 17:13:23

回答