奇怪的Python错误

时间:2017-03-13 18:39:44

标签: python django

此错误:select c.CustomerID 'Customer ID', c.CompanyName 'Company Name', c.ContactName 'Contact Name', c.Address, c.City, c.StateOrRegion 'State Or Region', c.PostalCode 'Postal Code', c.Country, c.Phone, c.Fax, o.OrderID 'Order ID', o.ShippedDate 'Shipped Date' from Customers c left join orders o on o.customerid = c.customerid where o.shippeddate is null order by c.ContactTitle asc

执行此方法时出现

cancel_agreement() missing 1 required positional argument: 'agreement_id'

以下是def force_cancel(self): api = model_from_ref(self.processor.api) api.cancel_agreement(self.subscription_reference) # transaction.cancel_subscription() # runs in the callback 方法:

cancel_agreement()

我不明白为什么会发生错误:它调用一个双参数函数(def cancel_agreement(self, agreement_id, is_upgrade=False): note = _("Upgrading billing plan") if is_upgrade else _("Canceling a service") r = self.session.post(self.server + '/v1/payments/billing-agreements/%s/cancel' % agreement_id, data='{"note": "%s"}' % note, headers={'content-type': 'application/json'}) if r.status_code != requests.codes.ok: raise RuntimeError(_("Cannot cancel a billing agreement at PayPal. Please contact support.")) api),它的定义也是两个必需参数(self.subscription_reference和{ {1}})。

可悲的是,我无法显示整个代码,因为我的业务合作伙伴反对将其发布为开源代码。

1 个答案:

答案 0 :(得分:1)

应该是:

def force_cancel(self):
    klass = model_from_ref(self.processor.api)
    api = klass()
    api.cancel_agreement(self.subscription_reference)