我有一个自定义内容类型。仅当是匿名用户时,我才需要覆盖此对象的基本 View :
class Imagesblock(folder.ATFolder):
.......
def index_html(self):
""" use the parent view """
portal_state = getMultiAdapter((self, self.REQUEST), name="plone_portal_state")
if portal_state.anonymous()==True:
response = self.REQUEST.response
url = self.aq_parent.absolute_url()
return response.redirect(url, status=303)
else:
return super(Imagesblock).index_html()
我本应使用父类(super class)的 index_html,但出现错误:
AttributeError: 'super' object has no attribute 'index_html'
有什么建议吗? 维托
请您参考如下方法:
如果你想使用父类(super class)中的方法index_html(),你应该调用它
folder.ATFolder.index_html(self)
假设 folder.ATFolder 是父类(super class)的名称。
编辑:
正如@Mathias 提到的,您也可以将其称为:
super(Imagesblock, self).index_html()
