j2labs/dictshield — Issue #46: 'dict' object has no attribute 'to_json' marshalling problem for complex Documents
Author: alexanderdean
Created: 2011-12-03 13:22:21+00:00
State: open

There's an issue with `make_json_*safe` for complex representations. Here is the error:

Traceback (most recent call last):
File "./scratchpad.py", line 205, in
data = rep.make_json_ownersafe(rep)
File "/home/alex/Development/Git/Orderly/orderly-mdm/sql/src/dictshield/dictshield/document.py", line 183, in make_json_ownersafe
white_list=white_list)
File "/home/alex/Development/Git/Orderly/orderly-mdm/sql/src/dictshield/dictshield/document.py", line 151, in make_safe
doc_dict[k] = doc_converter(v)
File "/home/alex/Development/Git/Orderly/orderly-mdm/sql/src/dictshield/dictshield/document.py", line 177, in
doc_converter = lambda d: d.make_json_ownersafe(doc_encoder(d), encode=False)
File "/home/alex/Development/Git/Orderly/orderly-mdm/sql/src/dictshield/dictshield/document.py", line 183, in make_json_ownersafe
white_list=white_list)
File "/home/alex/Development/Git/Orderly/orderly-mdm/sql/src/dictshield/dictshield/document.py", line 156, in make_safe
doc_dict[k] = field_converter(k, v)
File "/home/alex/Development/Git/Orderly/orderly-mdm/sql/src/dictshield/dictshield/document.py", line 175, in
field_converter = lambda f, v: cls._fields[f].for_json(v)
File "/home/alex/Development/Git/Orderly/orderly-mdm/sql/src/dictshield/dictshield/fields/base.py", line 604, in for_json
return value.to_json(encode=False)
AttributeError: 'dict' object has no attribute 'to_json'

There's a gist with a complete test script for this problem here: https://gist.github.com/1427099