ozgur / python-firebase

Python interface to the Firebase's REST API
http://ozgur.github.com/python-firebase/
MIT License
593 stars 155 forks source link

TypeError: get() got multiple values for keyword argument 'connection' #19

Closed fosstrack closed 10 years ago

fosstrack commented 10 years ago

Following the get examples in the documentation, here's my ipython session. Using python 2.7.3.

In [1]: from firebase import firebase In [2]: f = firebase.FirebaseApplication('https://.firebaseio.com') In [3]: result = f.get('/pins/3', None, None, {'print': 'pretty'}, {'X_FANCY_HEADER': 'VERY FANCY'})


TypeError Traceback (most recent call last)

in () ----> 1 result = f.get('/pins/3', None, None, {'print': 'pretty'}, {'X_FANCY_HEADER': 'VERY FANCY'}) /home/vagrant/venv/cooliyo/local/lib/python2.7/site-packages/firebase/decorators.pyc in wrapped(_args, *_kwargs) 17 connection.timeout = timeout 18 connection.headers.update({'Content-type': 'application/json'}) ---> 19 return f(_args, *_kwargs) 20 return wraps(f)(wrapped) 21 return wrapper TypeError: get() got multiple values for keyword argument 'connection' --- i think the decorator is feeding the 'connection' as a keyword arg, when the get function expects the connection as a positional arg (index = 3) and there are other positional args after it. Has anyone else run into this problem. Fixed this by modifying the decorator (http_connection) to update the positional arg instead of kwarg. I am sure I am missing something obvious.
fosstrack commented 10 years ago

As a workaround, you could always call get / put / post using keyword arguments:

result = f.get('/pins/3', name=None, connection=None, params={'print': 'pretty'}, headers={'X_FANCY_HEADER': 'VERY FANCY'})

iongion commented 10 years ago

this is not working, how did you patch the decorator ?

ozgur commented 10 years ago

It's been fixed by https://github.com/ozgur/python-firebase/pull/25. Closing this one.

river-fall commented 8 years ago

Hi @ozgur! I still have the same issue:

#!/usr/local/bin/python3
from firebase import firebase
authentication = firebase.FirebaseAuthentication('password', 'username@domain.com')
myFirebase = firebase.FirebaseApplication('https://myproject.firebaseio.com',authentication)
result = myFirebase.get('/link', None, {'print': 'pretty'})
print (result)

bash-3.2$ ./1.py Traceback (most recent call last): File "./1.py", line 11, in result = myFirebase.get('/link', None, {'print': 'pretty'}) File "/usr/local/lib/python3.5/site-packages/firebase/decorators.py", line 19, in wrapped return f(_args, *_kwargs) TypeError: get() got multiple values for argument 'connection'

quique123 commented 8 years ago

I've got the same error:

Traceback (most recent call last): File "firebaseconnect.py", line 12, in result = firebase.get('/users', None, {'print': 'pretty'}) File "/usr/local/lib/python2.7/dist-packages/firebase/decorators.py", line 19, in wrapped return f(_args, *_kwargs) TypeError: get() got multiple values for keyword argument 'connection'

Im using this code:

from firebase import firebase
from firebase.firebase import FirebaseApplication, FirebaseAuthentication

authentication = firebase.FirebaseAuthentication('pass123', 'info@santiapps.com', extra={'id': 123})
firebase = firebase.FirebaseApplication('https://mystorage.firebaseio.com', authentication)
firebase.authentication = authentication
print authentication.extra

user = authentication.get_user()
print user.firebase_auth_token

result = firebase.get('/users', None, {'print': 'pretty'})
print result

Please help?

ashokmagadum commented 5 years ago

I tried same code sample of quique123 and received same error.

My code:

from firebase import firebase
from firebase.firebase import FirebaseApplication, FirebaseAuthentication
authentication = firebase.FirebaseAuthentication('passcode', 'dummyacct@dummy.com')
firebase = firebase.FirebaseApplication('https://myapp.firebaseio.com', authentication)
firebase.authentication = authentication
print (authentication.extra)

user = authentication.get_user()
print (user.firebase_auth_token)

result = firebase.get('/users', None, {'print': 'pretty'})
print (result)

Error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-21-974ae75a3869> in <module>
      9 print (user.firebase_auth_token)
     10 
---> 11 result = firebase.get('/users', None, {'print': 'pretty'})
     12 print (result)
     13 

/anaconda3/envs/py36/lib/python3.6/site-packages/firebase/decorators.py in wrapped(*args, **kwargs)
     17             connection.timeout = timeout
     18             connection.headers.update({'Content-type': 'application/json'})
---> 19             return f(*args, **kwargs)
     20         return wraps(f)(wrapped)
     21     return wrapper

TypeError: get() got multiple values for argument 'connection'

I'm running this code on Python 3.6.8 :: Anaconda, Inc.

Please help.

ferventer commented 5 years ago

firebase.get('/users', None, {'print': 'pretty'})

Try this istead: firebase.get('/users', None, connection=None, params={'print': 'pretty'})