python - 重写自定义内容类型的方法index_html

标签 python plone

我有一个自定义内容类型。仅当匿名用户时,我才需要覆盖此对象的基本 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/

相关文章:

python - PyQt5 - 为什么进度条不显示文件复制进度?

python - 用python解析xml中的CDATA

python - python中多线程应用程序中的段错误错误

导航 portlet : all childen always expanded

python - collective.googleanalytics 报告带有包含标签的过滤器

session - Plone session 永远持续

plone - PloneFormGen 中的 Likert 选项是否可以设置为在作为电子邮件提交并存储在数据适配器中时显示带有答案的问题

python - 什么可以证明 Plone 的复杂性?

python - 如何使用修改后的 OpenSSL(具有俄罗斯 GOST 支持)编译 python?

python urllib2 返回垃圾