# Path: editlive/conf/settings.py
# DATE_FORMAT = getattr(settings, 'DATE_FORMAT')
# DATETIME_FORMAT = getattr(settings, 'DATETIME_FORMAT')
# DATE_WIDGET_FORMAT = getattr(settings, 'EDITLIVE_DATE_WIDGET_FORMAT', 'yy-mm-dd')
# TIME_WIDGET_FORMAT = getattr(settings, 'EDITLIVE_TIME_WIDGET_FORMAT', 'hh:mm')
# EDITLIVE_DEFAULT_ADAPTORS = {
#     # Fields
#     'char':     'editlive.adaptors.CharAdaptor',
#     'text':     'editlive.adaptors.TextAdaptor',
#     'date':     'editlive.adaptors.DateAdaptor',
#     'datetime': 'editlive.adaptors.DateTimeAdaptor',
#     'boolean':  'editlive.adaptors.BooleanAdaptor',
#     'fk':       'editlive.adaptors.ForeignKeyAdaptor',
#     'choices':  'editlive.adaptors.ChoicesAdaptor',
#     'm2m':      'editlive.adaptors.ManyToManyAdaptor',
#     'time':     'editlive.adaptors.TimeAdaptor',
#    #'file':     'editlive.adaptors.FileAdaptor',
#    #'image':    'editlive.adaptors.ImageAdaptor',
# 
#    # Inlines
#    'tabular':   'editlive.adaptors.TabularInlineAdaptor',
#    'stacked':   'editlive.adaptors.StackedInlineAdaptor',
# }


import re
import collections
import urllib
from django import template
from django.db import models
from django.conf import settings
from django.forms import ModelForm
from django.db.models.fields.related import ForeignKey, ManyToManyField
from editlive.conf import settings as editlive_settings
        from django.utils.importlib import import_module
    manytomany_list = obj._meta.many_to_many
    for manytomany in manytomany_list:
        val = manytomany.value_from_object(obj)
        if isinstance(val, collections.Iterable):
            ids = [obj_rel.id for obj_rel in val]
            if ids:
                obj_dict_result[manytomany.name] = ids

    return obj_dict_result


def apply_filters(value, filters, load_tags=None):
    if filters:
        filters_str = '|%s' % '|'.join(filters)
        load_tags = load_tags or []
        if load_tags:
            load_tags_str = "{%% load %s %%}" % ' '.join(load_tags)
        else:
            load_tags_str = ""
        ctx = template.Context({'value': value})
        value = template.Template("""%s{{ value%s }}""" % (\
                load_tags_str, filters_str)).render(ctx)
    return value


def encodeURI(uri):
    """
    We really only need to escape " (double quotes) and non-ascii characters..
    """
    s = u"""!#$&'()*+,-./:;<=>?@[\]^_{|}~ """

# Path: editlive/conf/settings.py
# DATE_FORMAT = getattr(settings, 'DATE_FORMAT')
# DATETIME_FORMAT = getattr(settings, 'DATETIME_FORMAT')
# DATE_WIDGET_FORMAT = getattr(settings, 'EDITLIVE_DATE_WIDGET_FORMAT', 'yy-mm-dd')
# TIME_WIDGET_FORMAT = getattr(settings, 'EDITLIVE_TIME_WIDGET_FORMAT', 'hh:mm')
# EDITLIVE_DEFAULT_ADAPTORS = {
#     # Fields
#     'char':     'editlive.adaptors.CharAdaptor',
#     'text':     'editlive.adaptors.TextAdaptor',
#     'date':     'editlive.adaptors.DateAdaptor',
#     'datetime': 'editlive.adaptors.DateTimeAdaptor',
#     'boolean':  'editlive.adaptors.BooleanAdaptor',
#     'fk':       'editlive.adaptors.ForeignKeyAdaptor',
#     'choices':  'editlive.adaptors.ChoicesAdaptor',
#     'm2m':      'editlive.adaptors.ManyToManyAdaptor',
#     'time':     'editlive.adaptors.TimeAdaptor',
#    #'file':     'editlive.adaptors.FileAdaptor',
#    #'image':    'editlive.adaptors.ImageAdaptor',
# 
#    # Inlines
#    'tabular':   'editlive.adaptors.TabularInlineAdaptor',
#    'stacked':   'editlive.adaptors.StackedInlineAdaptor',
# }


# Path: editlive/utils.py
import re
import collections
import urllib
from django import template
from django.db import models
from django.conf import settings
from django.forms import ModelForm
from django.db.models.fields.related import ForeignKey, ManyToManyField
from editlive.conf import settings as editlive_settings
        from django.utils.importlib import import_module

    manytomany_list = obj._meta.many_to_many
    for manytomany in manytomany_list:
        val = manytomany.value_from_object(obj)
        if isinstance(val, collections.Iterable):
            ids = [obj_rel.id for obj_rel in val]
            if ids:
                obj_dict_result[manytomany.name] = ids

    return obj_dict_result


def apply_filters(value, filters, load_tags=None):
    if filters:
        filters_str = '|%s' % '|'.join(filters)
        load_tags = load_tags or []
        if load_tags:
            load_tags_str = "{%% load %s %%}" % ' '.join(load_tags)
        else:
            load_tags_str = ""
        ctx = template.Context({'value': value})
        value = template.Template("""%s{{ value%s }}""" % (\
                load_tags_str, filters_str)).render(ctx)
    return value


def encodeURI(uri):
    """
    We really only need to escape " (double quotes) and non-ascii characters..
    """
    s = u"""!#$&'()*+,-./:;<=>?@[\]^_{|}~ """

    return urllib.quote(unicode(uri).encode('utf8'), safe=s.encode('ascii'))