def get_ref(obj):
    """
    Get string reference to object. Stores a weak reference in a dictionary
    using the object's id as the key. If the object cannot be weakly
    referenced (e.g. dictionaries, frame objects), store a strong references
    in a classic dictionary.

    Returns the object's id as a string.
    """
    oid = id(obj)
    try:
        server.id2ref[oid] = obj
    except TypeError:
        server.id2obj[oid] = obj
    return str(oid)