Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I thought at first that the problem was quite simple, but then you posted a traceback contradicting the original error message. However, I think the problem is still pretty straightforward, assuming that the <em>traceback</em> error is the correct one. Recall that this:</p> <pre><code>@decorator def foo(x): return x + 1 </code></pre> <p>Is simply syntactic sugar for this:</p> <pre><code>def foo(x): return x + 1 foo = oauth_machine.auth(foo) </code></pre> <p>So when you use <code>@oauth_machine.auth</code> on <code>get</code>, it's passed via a closure into <code>inner</code> as <code>fn</code>.</p> <pre><code>def auth(fn): def inner(self): res = get_user_by_credentials(self, fn, callback=done_auth) return inner </code></pre> <p>It's then passed into <code>get_user_by_credentials</code>, again as <code>fn</code>, which in turn produces another closure, which passes <code>fn</code> to <code>callback</code>. </p> <pre><code>def get_user_by_credentials(self, fn, callback): def onFetchUserCredentials(result, error): self.user = result callback(self, fn) </code></pre> <p><code>callback</code> was defined as <code>done_auth</code> back in <code>inner</code>, so that menas that <code>fn</code> (i.e. the original <code>get</code>) is passed there, and then called on <code>result</code>:</p> <pre><code>def done_auth(result, fn): return fn(result) </code></pre> <p>But <code>fn</code> (i.e. <code>get</code>) takes two arguments. You pass it only one, causing an error. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload