def get_adapter_for_persistent_model(self, persistent_model, rest_model=None):
persistent_signature = self.generate_signature(persistent_model)<EOL>if persistent_signature in self._persistent_map:<EOL><INDENT>sub_map = self._persistent_map[persistent_signature]<EOL>if rest_model is None:<EOL><INDENT>return self._persistent_map[persistent_signature][self.DEFAULT_REST_ADAPTER]<EOL><DEDENT>else:<EOL><INDENT>rest_sig = self.generate_signature(rest_model)<EOL>if rest_sig in sub_map:<EOL><INDENT>return self._persistent_map[persistent_signature][rest_sig]<EOL><DEDENT><DEDENT><DEDENT>raise TypeError("<STR_LIT>" % persistent_signature)<EOL>
:param persistent_model: instance of persistent model
:param rest_model: specific REST model
:return: the matching model adapter
:rtype: ModelAdapter