def get_related_model(model, relationname):
 mapper = sqlalchemy_inspect(model)
 attribute = mapper.all_orm_descriptors[relationname]
 hasattr(model, relationname)
 return get_related_model_from_attribute(attribute)

def get_related_model ( model , relationname ) : mapper = sqlalchemy_inspect ( model ) attribute = mapper . all_orm_descriptors [ relationname ] hasattr ( model , relationname ) return get_related_model_from_attribute ( attribute )
gets the class of the model to which model is related by the attribute whose name is relationname .