def context_and_key(key):
    """Return a tuple containing the context (or None) and the message
    key."""
    # A context, if present, is prepended to the key, with a \x04
    # character in between.
    (context, separator, k) = key.partition(u'\x04')
    if (separator != ''):
        return (context, k)
    else:
        return (None, key)