def adapt_persistent_instance(persistent_object, target_rest_class=None, attribute_filter=None):
<EOL>if target_rest_class is None:<EOL><INDENT>adapter_instance = registry.get_adapter_for_persistent_model(persistent_object)<EOL><DEDENT>else:<EOL><INDENT>if inspect.isclass(target_rest_class):<EOL><INDENT>target_rest_class = target_rest_class()<EOL><DEDENT>adapter_instance = registry.get_adapter_for_persistent_model(persistent_object, target_rest_class)<EOL><DEDENT>if attribute_filter is not None and isinstance(attribute_filter, parser.AttributeFilter):<EOL><INDENT>parser.AttributeFilter.from_model(target_rest_class).conforms_to_template_filter(attribute_filter)<EOL><DEDENT>if isinstance(attribute_filter, parser.AttributeFilter):<EOL><INDENT>attribute_filter = attribute_filter.as_immutable()<EOL><DEDENT>return adapter_instance.adapt_persistent_to_rest(persistent_object, attribute_filter)<EOL>
Adapts a single persistent instance to a REST model; at present this is a
common method for all persistent backends.

Refer to: https://groups.google.com/forum/#!topic/prestans-discuss/dO1yx8f60as
for discussion on this feature