標準のATImageを含むDexterityフォルダーっぽいタイプがあります。フォルダまたはコレクションの概要ビューにリストされているときに、含まれている最初の画像を表示したいのですが。ビューに画像プロパティを設定しようとしましたが、その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
代わりに何をすべきですか?