super()参数1必须是类型,而不是非

2024-10-01 17:41:09 发布

您现在位置:Python中文网/ 问答频道 /正文

在我的django应用程序的一个模块中,一个类在使用super。。。在

class LinkshareExternalAffiliateProperties(AffiliateExternalProperties):

    def __init__(self, aggregator_affiliate_id, account_username, account_password, api_token):
        super(LinkshareExternalAffiliateProperties, self).__init__(aggregator_affiliate_id)
        self.account_username = account_username
        self.account_password = account_password
        self.api_token = api_token

class AffiliateExternalProperties(object):

    def __getattribute__(self, attr):
        sources = super(AffiliateExternalProperties, self).__getattribute__('__sources__')
        if attr in sources:
            return self.get(attr)
        else:
            return super(AffiliateExternalProperties, self).__getattribute__(attr)

当代码被调用时,我得到一个错误:super()参数1必须是type,而不是None LinkshareExternalAffiliateProperties如何计算为None?它是这个新实例的类!!同一模块中的其他类此时也不可用。在

一些有趣的事情(这整件事很复杂,但整个故事的某些部分可能是造成问题的原因……:

^{pr2}$

在浏览器中点击/查看会引发错误。。。在

kicker,在本地运行这段代码,在不引起错误的情况下工作正常。在

当我使用gunicorn&nginx运行它时,它会出错。在


Tags: 模块selftokenapi错误usernameaccountpassword
2条回答

你在分配完课程后不宣布。以下将导致您看到的错误:

class foo(object):
    def x(self):
        print "foo"

class bar(foo):
    def x(self):
        super(bar, self).x()

baz = bar
bar = None

a = baz()
a.x()

Gunicorn有一个bug:

djangorun_gunicorn+重新加载

one possibility to fix reload using Django 'un_gunicorn' command with manage.py would be to consider that reload == reexec. So we are making sure we reload all modules. But with this solution the process id will change and some supervisor may not be abble to detect the change if they aren't using the pidfile. (In other word we should strongly advise people to use gunicorn_django command if they want HUP support.)

https://github.com/benoitc/gunicorn/issues/222

相关问题 更多 >

    热门问题