lsbardel / python-stdnet

Object-data mapper and advanced query manager for non relational databases
http://lsbardel.github.com/python-stdnet/
BSD 3-Clause "New" or "Revised" License
120 stars 20 forks source link

TypeError trying to run simple example from the documentation #85

Open rcalsaverini opened 9 years ago

rcalsaverini commented 9 years ago

Hi there.

I was trying to run a simple example from the docs to see if stdnet was usefull for a project but I keep getting a TypeError: <lambda>() takes no arguments (1 given).

The example is this:

from stdnet import odm

class Fund(odm.StdModel):
    name = odm.SymbolField(unique=True)
    ccy = odm.SymbolField()
    description = odm.CharField()

    def __unicode__(self):
        return self.name

if __name__ == "__main__":
    models = odm.Router('redis://localhost:6379')

    models.register(Fund)
    models.register(Instrument)
    models.register(Position)

    with models.session().begin() as transaction:
        transaction.add(models.fund(name='Markowitz', ccy='EUR'))

And the traceback is this:

(recsys)[/tmp]$ python fund.py
Traceback (most recent call last):
  File "fund.py", line 42, in <module>
    transaction.add(models.fund(name='Markowitz', ccy='EUR'))
  File "/home/calsaverini/.virtualenvs/recsys/local/lib/python2.7/site-packages/stdnet/odm/session.py", line 434, in __exit__
    return self.commit()
  File "/home/calsaverini/.virtualenvs/recsys/local/lib/python2.7/site-packages/stdnet/odm/session.py", line 454, in commit
    self.on_result = self._commit()
  File "/home/calsaverini/.virtualenvs/recsys/local/lib/python2.7/site-packages/stdnet/utils/async.py", line 76, in _
    return execute_generator(f(*args, **kwargs))
  File "/home/calsaverini/.virtualenvs/recsys/local/lib/python2.7/site-packages/stdnet/utils/async.py", line 40, in execute_generator
    result = gen.send(result)
  File "/home/calsaverini/.virtualenvs/recsys/local/lib/python2.7/site-packages/stdnet/odm/session.py", line 471, in _commit
    multi.append(backend.execute_session(data))
  File "/home/calsaverini/.virtualenvs/recsys/local/lib/python2.7/site-packages/stdnet/backends/redisb/__init__.py", line 839, in execute_session
    return pipe.execute()
  File "/home/calsaverini/.virtualenvs/recsys/local/lib/python2.7/site-packages/stdnet/backends/redisb/client.py", line 350, in execute
    raise_on_error=raise_on_error)
  File "/home/calsaverini/.virtualenvs/recsys/local/lib/python2.7/site-packages/stdnet/backends/redisb/client.py", line 152, in request_pipeline
    conn = self.get_connection('MULTI', pipeline.shard_hint)
  File "/home/calsaverini/.virtualenvs/recsys/local/lib/python2.7/site-packages/redis/connection.py", line 874, in get_connection
    connection = self.make_connection()
  File "/home/calsaverini/.virtualenvs/recsys/local/lib/python2.7/site-packages/redis/connection.py", line 883, in make_connection
    return self.connection_class(**self.connection_kwargs)
  File "/home/calsaverini/.virtualenvs/recsys/local/lib/python2.7/site-packages/redis/connection.py", line 405, in __init__
    self._parser = parser_class(socket_read_size=socket_read_size)
TypeError: <lambda>() takes no arguments (1 given)

I'm pretty sure it must be something dumb I did, but I couldn't find the problem. The version of stdnet is python-stdnet==0.8.2 installed via pip.

mehmetb commented 9 years ago

Python-stdnet 0.8.2 Redis 2.8.13 Python 2.7.9 (GCC 4.9.1 on linux2) Ubuntu 14.10

Exactly the same output for me too

nooperpudd commented 9 years ago

@mehmetb @rcalsaverini .The same happened to me. So the solution to solve the problems, You better to install the github master branch. you can fix the errors .