Hello everyone. We are using a mongodb for our application an ran into a little problem.
We declare the following table: db.define_table("pricing_plan", Field("title", "string", notnull=True), Field("image", "upload"), Field("description", "text"), Field("price", "integer", notnull=True )) And when we try to populate some info through the database administrator in the admin interface we get the following error: <type 'exceptions.TypeError'> data must be an instance of str Versión web2py™ Version 2.7.4-stable+timestamp.2013.10.14.15.16.29 Python Python 2.7.3: /usr/bin/python (prefix: /usr) Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. Traceback (most recent call last): File "/home/francisco/bytecam/web2py/gluon/restricted.py", line 217, in restricted exec ccode in environment File "/home/francisco/bytecam/web2py/applications/olifant/controllers/appadmin.py" <http://127.0.0.1:8000/admin/default/edit/olifant/controllers/appadmin.py>, line 635, in <module> File "/home/francisco/bytecam/web2py/gluon/globals.py", line 372, in <lambda> self._caller = lambda f: f() File "/home/francisco/bytecam/web2py/applications/olifant/controllers/appadmin.py" <http://127.0.0.1:8000/admin/default/edit/olifant/controllers/appadmin.py>, line 152, in insert if form.accepts(request.vars, session): File "/home/francisco/bytecam/web2py/gluon/sqlhtml.py", line 1518, in accepts self.vars.id = self.table.insert(**fields) File "/home/francisco/bytecam/web2py/gluon/dal.py", line 8781, in insert ret = self._db._adapter.insert(self, self._listify(fields)) File "/home/francisco/bytecam/web2py/gluon/dal.py", line 5614, in insert values = self._insert(table, fields) File "/home/francisco/bytecam/web2py/gluon/dal.py", line 5604, in _insert values[fieldname] = self.represent(v, fieldtype) File "/home/francisco/bytecam/web2py/gluon/dal.py", line 5408, in represent return Binary(value) File "/usr/lib/python2.7/dist-packages/bson/binary.py", line 109, in __new__ "instance of %s" % (binary_type.__name__,)) TypeError: data must be an instance of str At first I thought we were doing something wrong, but after checking several times our code I decied to look at the dal code and it seem that line 5408 is trying to convert None in a Binary. I put the code fragment below. 5405 elif fieldtype == "blob": 5406 from bson import Binary 5407 if not isinstance(value, Binary): 5408 return Binary(value) 5409 return value In the python console I did: from bson import Binary and then Binary(None) and it returns the same error. The thing is how do I fix this? I tried: 5405 elif fieldtype == "blob": if value== None: return value 5406 from bson import Binary 5407 if not isinstance(value, Binary): 5408 return Binary(value) 5409 return value But ain't sure if that is right or not. Hope someone can help me. Thanks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.