def encode(data, mime_type='', charset='utf-8', base64=True):
    if isinstance(data, six.text_type):
        data = data.encode(charset)
    else:
        charset = None
    if base64:
        data = utils.text(b64encode(data))
    else:
        data = utils.text(quote(data))

    result = ['data:', ]
    if mime_type:
        result.append(mime_type)
    if charset:
        result.append(';charset=')
        result.append(charset)
    if base64:
        result.append(';base64')
    result.append(',')
    result.append(data)

    return ''.join(result)
Get the name to use for the object.
dataset/ETHPy150Open binux/pyspider/pyspider/libs/dataurl.py/encode--crossover with--dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Django-1.6.10/django/views/generic/detail.py/SingleObjectMixin.get_context_object_name