def _serialize_opaque_key(self, key):
if hasattr(key, '<STR_LIT>'):<EOL><INDENT>return key.to_deprecated_string()<EOL><DEDENT>else:<EOL><INDENT>return unicode(key)<EOL><DEDENT>
Gracefully handle opaque keys, both before and after the transition.
https://github.com/edx/edx-platform/wiki/Opaque-Keys

Currently uses `to_deprecated_string()` to ensure that new keys
are backwards-compatible with keys we store in ORA2 database models.

Args:
    key (unicode or OpaqueKey subclass): The key to serialize.

Returns:
    unicode