Add get_appropriate_subclass to XFormInstance, dispatched on doc_type

This function enables the fetching of archived / deleted forms, according to the appropriate subclass. This is generally useful, but specifically to support serving archived forms through the API.