def METHOD_NAME(*args, **kw):
    pickler = pickle.Pickler(*args, **kw)
    def persistent_id(obj):
        # print "serializing:", repr(obj)
        if isinstance(obj, QueryableAttribute):
            cls = obj.impl.class_
            key = obj.impl.key
            id = "attribute:" + key + ":" + b64encode(pickle.dumps(cls))
        elif isinstance(obj, Mapper) and not obj.non_primary:
            id = "mapper:" + b64encode(pickle.dumps(obj.class_))
        elif isinstance(obj, MapperProperty) and not obj.parent.non_primary:
            id = "mapperprop:" + b64encode(pickle.dumps(obj.parent.class_)) + \
                ":" + obj.key
        elif isinstance(obj, Table):
            id = "table:" + text_type(obj.key)
        elif isinstance(obj, Column) and isinstance(obj.table, Table):
            id = "column:" + \
                text_type(obj.table.key) + ":" + text_type(obj.key)
        elif isinstance(obj, Session):
            id = "session:"
        elif isinstance(obj, Engine):
            id = "engine:"
        else:
            return None
        return id
    pickler.persistent_id = persistent_id
    return pickler