Hi,
I'm running stdnet 0.8.2 w/ Cython, on Python 2.6.6, Debian 6.0 (kernel 2.6.32-5-amd64).
I'm working through the tutorials on the website, and I'm having a hard time with the first one. When I run
Broken Example (below), I get the
Traceback unless I manually specify the value of id when I populate my models (as shown in
Working Example). Please be aware that I removed some debugging code so the line numbers in the traceback won't line up with what I posted.
Am I doing something wrong in the Broken Example, or is this a bug?
Thoughts?
----
Traceback:
Traceback (most recent call last):
File "stdnet_example.py", line 31, in <module>
session.commit()
File "/usr/local/lib/python2.6/dist-packages/python_stdnet-0.8.2-py2.6.egg/stdnet/odm/session.py", line 609, in commit
return self.transaction.commit()
File "/usr/local/lib/python2.6/dist-packages/python_stdnet-0.8.2-py2.6.egg/stdnet/odm/session.py", line 454, in commit
self.on_result = self._commit()
File "/usr/local/lib/python2.6/dist-packages/python_stdnet-0.8.2-py2.6.egg/stdnet/utils/async.py", line 76, in _
return execute_generator(f(*args, **kwargs))
File "/usr/local/lib/python2.6/dist-packages/python_stdnet-0.8.2-py2.6.egg/stdnet/utils/async.py", line 40, in execute_generator
result = gen.send(result)
File "/usr/local/lib/python2.6/dist-packages/python_stdnet-0.8.2-py2.6.egg/stdnet/odm/session.py", line 471, in _commit
multi.append(backend.execute_session(data))
File "/usr/local/lib/python2.6/dist-packages/python_stdnet-0.8.2-py2.6.egg/stdnet/backends/redisb/__init__.py", line 820, in execute_session
json.dumps(instance._dbdata['errors']))
stdnet.utils.exceptions.FieldValueError: {"author_id": "Field 'author_id' is required for '__main__.book'."}----
Broken Example:from stdnet import odm
class Author(odm.StdModel):
id = odm.AutoIdField(primary_key=True, unique=True, required=True)
name = odm.SymbolField()
def __unicode__(self):
return self.name
class Book(odm.StdModel):
id = odm.AutoIdField(primary_key=True, unique=True, required=True)
title = odm.CharField()
author = odm.ForeignKey(Author, related_name='books')
def __unicode__(self):
return "<Book '%s' by %s>" % (self.title, self.author)
if __name__=='__main__':
models = odm.Router('redis://localhost:6379?db=0')
models.register(Author)
models.register(Book)
session = models.session()
session.begin()
author1 = models[Author](name='Jeff Doyle')
session.add(author1)
book1 = models[Book](title='Routing TCP/IP, Volume 1', author=author1)
session.add(book1)
session.commit()----
Working Example:from stdnet import odm
class Author(odm.StdModel):
id = odm.AutoIdField(primary_key=True, unique=True, required=True)
name = odm.SymbolField()
def __unicode__(self):
return self.name
class Book(odm.StdModel):
id = odm.AutoIdField(primary_key=True, unique=True, required=True)
title = odm.CharField()
author = odm.ForeignKey(Author, related_name='books')
def __unicode__(self):
return "<Book '%s' by %s>" % (self.title, self.author)
if __name__=='__main__':
models = odm.Router('redis://localhost:6379?db=0')
models.register(Author)
models.register(Book)
session = models.session()
session.begin()
author1 = models[Author](name='Jeff Doyle', id=1)
session.add(author1)
book1 = models[Book](title='Routing TCP/IP, Volume 1', id=2, author=author1)
session.add(book1)
session.commit()