我有一个自定义内容类型。仅当匿名用户时,我才需要覆盖此对象的基本 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()
关于python - 重写自定义内容类型的方法index_html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21165661/