I have a simple web application which is using python 2.7 BaseHTTPServer (built-in in python itself) and then I created a rest api based on Tal Liron work (https://gist.github.com/tliron/8e9757180506f25e46d9).
Now I created a rest api to return a complex object from DB by using following code:
order = session.query(Order).filter(Order.id == 10).one()
and then I am sending the order to printer but I got following error:
File "c:softsrcbuildoprout00-PYZ.pyzbusiness", line 259, in do_print
File "c:softsrcbuildoprout00-PYZ.pyzbusiness", line 415, in rows
File "c:softsrcbuildoprout00-PYZ.pyzsqlalchemy.orm.attributes", line 168, in __get__
File "c:softsrcbuildoprout00-PYZ.pyzsqlalchemy.orm.attributes", line 453, in get
File "c:softsrcbuildoprout00-PYZ.pyzsqlalchemy.orm.strategies", line 508, in _load_for_state
File "c:softsrcbuildoprout00-PYZ.pyzsqlalchemy.orm.strategies", line 574, in _emit_lazyload
File "c:softsrcbuildoprout00-PYZ.pyzsqlalchemy.orm.query", line 2115, in all
File "c:softsrcbuildoprout00-PYZ.pyzsqlalchemy.orm.query", line 2365, in instances
File "c:softsrcbuildoprout00-PYZ.pyzsqlalchemy.orm.state", line 399, in commit
KeyError: 'type'
I do not have any ‘type’ attribute probably it is used to discriminate child instances .. however I understand the object is still attached to session and since I do not need it I tried to expunge it from session but I got same error.
The do_print method is simply reading the object (rows) and using tempita to populate the report. But the navigation of the object seems interacting with sqlalchemy (which I would like to avoid because it is not required) and then got the error.
thanks for any help