I'm getting Unicode errors while trying to add data to Neo4J via Bulbs when the data contains non-ascii data.
the following code fails:
from bulbs.model import Node
from bulbs.property import String
from bulbs.neo4jserver import Graph
class User(Node):
element_type="user"
name = String(nullable=False)
g = Graph()
g.add_proxy("users", User)
user_data = {u'name': u'Aname M\xf6ller'}
g.users.create(**user_data)
with a UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 7: ordinal not in range(128)
The error is occurring in the bulbs.utils.u
function, via codecs.unicode_escape_decode()
.
Some hopefully relevant info:
$>python -V
'2.7.3'
>>>type(user_data['name'])
type('unicode')
>>>import bulbs
>>>bulbs.__version__
'0.3'
The Neo4J docs state that all String objects are saved as unicode, so why is my unicode data not being accepted? I hope I am just missing something silly.
Yes, this was a bug. It's fixed in Bulbs 0.3.23:
https://github.com/espeed/bulbs/commit/7f104cdbc30f27ea76b036cfa0d0a694f074153e