why not just pass model_instance.__dict__ ?
On 7/23/07, HiTekElvis [EMAIL PROTECTED] wrote:
Anybody know a way to change a model into a dictionary?
For those to whom it means anything, I'm hoping to pass that
dictionary into a formencode.Schema.from_python method.
Any ideas?
-Josh
What do you mean by a model? If you are talking about an instance of a
mapped class, you could try something like this (untested):
def model_to_dict(instance):
model_dict = {}
for propname in instance.mapper.props:
model_dict[propname] = getattr(instance, propname)
return