# Path: dockit/forms/fields.py
# class HiddenJSONField(Field):
#     widget = HiddenInput
#     
#     def to_python(self, value):
#         if value and isinstance(value, basestring):
#             try:
#                 return json.loads(value)
#             except ValueError:
#                 raise ValidationError("Invalid JSON")#TODO more descriptive error?
#         return None
# 
#     def validate(self, value):
#         return Field.validate(self, value)
#     
#     def prepare_value(self, value):
#         if hasattr(value, 'to_primitive'):
#             return json.dumps(type(value).to_primitive(value))
#         return Field.prepare_value(self, value)


from django.forms import widgets
from django.utils.encoding import force_unicode
from django.forms.util import flatatt
from django.utils.safestring import mark_safe
from django.utils.html import escape
from django.utils import simplejson as json
from dockit.forms.fields import HiddenJSONField
from urllib import urlencode
            return mark_safe('%s<table><tr>%s</tr></table>' % (data_html, '</tr><tr>'.join(rows)))
        else:
            butn_html = self.render_button(dotpath, edit=bool(value))
            desc_html = self.get_label(dotpath, value)
            return mark_safe(''.join((data_html, desc_html, butn_html)))

class DotPathField(HiddenJSONField):
    widget = DotPathWidget
    
    def __init__(self, *args, **kwargs):
        self.dotpath = kwargs.pop('dotpath')
        self.params = kwargs.pop('params')
        #if 'widget' not in kwargs or self.widget == kwargs['widget']:
        #    kwargs['widget'] = self.widget(dotpath=self.dotpath)
        super(DotPathField, self).__init__(*args, **kwargs)
        self.widget.dotpath = self.dotpath
        self.widget.params = self.params
    
    def prepare_value(self, value):
        return value


class TypedSchemaFieldWidget(DotPathWidget):
    input_type = 'submit'
    
    def __init__(self, dotpath=None, schema_property=None):
        self.dotpath = dotpath
        self.schema_property = schema_property
        super(DotPathWidget, self).__init__()
    

# Path: dockit/forms/fields.py
# class HiddenJSONField(Field):
#     widget = HiddenInput
#     
#     def to_python(self, value):
#         if value and isinstance(value, basestring):
#             try:
#                 return json.loads(value)
#             except ValueError:
#                 raise ValidationError("Invalid JSON")#TODO more descriptive error?
#         return None
# 
#     def validate(self, value):
#         return Field.validate(self, value)
#     
#     def prepare_value(self, value):
#         if hasattr(value, 'to_primitive'):
#             return json.dumps(type(value).to_primitive(value))
#         return Field.prepare_value(self, value)


# Path: dockit/admin/fields.py
from django.forms import widgets
from django.utils.encoding import force_unicode
from django.forms.util import flatatt
from django.utils.safestring import mark_safe
from django.utils.html import escape
from django.utils import simplejson as json
from dockit.forms.fields import HiddenJSONField
from urllib import urlencode

            return mark_safe('%s<table><tr>%s</tr></table>' % (data_html, '</tr><tr>'.join(rows)))
        else:
            butn_html = self.render_button(dotpath, edit=bool(value))
            desc_html = self.get_label(dotpath, value)
            return mark_safe(''.join((data_html, desc_html, butn_html)))

class DotPathField(HiddenJSONField):
    widget = DotPathWidget
    
    def __init__(self, *args, **kwargs):
        self.dotpath = kwargs.pop('dotpath')
        self.params = kwargs.pop('params')
        #if 'widget' not in kwargs or self.widget == kwargs['widget']:
        #    kwargs['widget'] = self.widget(dotpath=self.dotpath)
        super(DotPathField, self).__init__(*args, **kwargs)
        self.widget.dotpath = self.dotpath
        self.widget.params = self.params
    
    def prepare_value(self, value):
        return value


class TypedSchemaFieldWidget(DotPathWidget):
    input_type = 'submit'
    
    def __init__(self, dotpath=None, schema_property=None):
        self.dotpath = dotpath
        self.schema_property = schema_property
        super(DotPathWidget, self).__init__()
    

    def render_type_dropdown(self, dotpath):