jfinkels/flask-restless — pull request #163 by bpedman (2013-03-17 00:28:49+00:00)
Title: Association proxy fails if the remote attribute is a column and not a relationship

I have an association proxy with the remote attribute as a unicode value. With the lastest changes on master I cannot get any object from the API that has a proxy like this. I get an exception like:

...snip...
File "/home/bpedersen/git/flask-restless/flask_restless/views.py", line 948, in _instid_to_dict
return self._inst_to_dict(inst)
File "/home/bpedersen/git/flask-restless/flask_restless/views.py", line 935, in _inst_to_dict
return _to_dict(inst, deep)
File "/home/bpedersen/git/flask-restless/flask_restless/views.py", line 229, in _to_dict
result[relation] = [_to_dict(inst, rdeep) for inst in relatedvalue]
File "/home/bpedersen/git/flask-restless/flask_restless/views.py", line 195, in _to_dict
columns = [p.key for p in object_mapper(instance).iterate_properties
File "/home/bpedersen/virtualenv/restless/lib/python2.7/site-packages/sqlalchemy/orm/util.py", line 1084, in object_mapper
return object_state(instance).mapper
File "/home/bpedersen/virtualenv/restless/lib/python2.7/site-packages/sqlalchemy/orm/util.py", line 1106, in object_state
raise exc.UnmappedInstanceError(instance)
UnmappedInstanceError: Class '__builtin__.unicode' is not mapped

This is easily reproducible in the tests by adding this column on the `ChosenProductImage` class to create a random number (could also create a random string to see the exact message I get):

name = Column(Integer, default=lambda: random.randint(1, 1000))

and then add the following to the `Product` class:

image_numbers = prox('chosen_product_images', 'name')