Класс в одном из моих модулей в моем приложении 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, not None Как LinkshareExternalAffiliateProperties оценивает None прямо здесь?Это класс этого нового экземпляра!Другие классы в том же модуле также недоступны в это время.
НЕКОТОРЫЕ ВЕЩИ ИНТЕРЕСА (Все это запутанно, но некоторая часть всей истории может быть тем, что создает проблему ...):
class Aggregator(models.Model):
foo = columns
@property
def proxy(self):
if self.name == 'Linkshare':
return Linkshare.objects.get_instance()
elif self.name == 'Commission Junction':
return CommissionJunction.objects.get_instance()
elif self.name == 'Share-A-Sale':
return ShareASale.objects.get_instance()
else:
raise Exception('Invalid aggregator name "%s". Excpected Linkshare, Commission Junction, or Share-A-Sale.' % self.name)
class Linkshare(models.Model):
def affiliate_properties(self, aggregator_affiliate_id):
return LinkshareExternalAffiliateProperties(aggregator_affiliate_id, self.username, self.password)
class Affiliate(models.Model):
foo = columns
def get_external_properties():
return self.aggregator.proxy.get_external_properties(self.aggregator_affiliate_id)
class MyView(self):
def view(self, request):
affiliate = get_object_or_404(Affiliate, pk=id)
properties = affiliate.get_external_properties()
return render_to_response('admin/affiliates/affiliate/affiliate_scrape_ajax.html', dict(scrape=properties))
Нажатие / просмотр в браузере вызывает ошибку ...
Кикер, запустив этот код, ЛОКАЛЬНО работает без ошибок.
КогдаЯ запускаю его с помощью gunicorn & nginx, он портится.