Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)

        def koData(queryset, field_names, name=None, safe=False):

    try:
        modelName = queryset[0].__class__.__name__    
        modelNameData = []

        if field_names:
            fields = field_names
        else:
            fields = get_fields(model)

        for obj in queryset:
            temp_dict = dict()
            for field in fields:
                try:
                    attribute = getattr(obj, str(field))

                    if not safe:
                        if isinstance(attribute, basestring):
                            attribute = cgi.escape(attribute)

                    temp_dict[field] = attribute
                except Exception, e:
                    continue
            modelNameData.append(temp_dict)

        if name:
            modelNameString = name
        else:
            modelNameString = modelName + "Data"

        dthandler = lambda obj: obj.isoformat() if isinstance(obj, datetime.datetime)  or isinstance(obj, datetime.date) else None
        return "var " + modelNameString + " = " + json.dumps(modelNameData, default=dthandler) + ';'
    except Exception, e:
        return ''
        


src/d/j/django-knockout-modeler-0.6.3/knockout_modeler/templatetags/knockout.py   django-knockout-modeler(Download)
from django import template
import simplejson as json
import datetime
from knockout_modeler.ko import ko, koData, koModel, koBindings, get_fields
 
 
    field_names = get_fields(values[0])
    return koData(values, field_names, name, safe)
 
def knockout_model(values):

src/d/j/django-knockout-modeler-HEAD/knockout_modeler/templatetags/knockout.py   django-knockout-modeler(Download)
from django import template
import simplejson as json
import datetime
from knockout_modeler.ko import ko, koData, koModel, koBindings, get_fields
 
 
    field_names = get_fields(values[0])
    return koData(values, field_names, name, safe)
 
def knockout_model(values):