# Path: dockit/forms/forms.py
# class DocumentForm(BaseDocumentForm):
#     """ The document form object """
#     __metaclass__ = DocumentFormMetaClass
# 
# def documentform_factory(document, form=DocumentForm, fields=None, exclude=None,
#                              formfield_callback=None, schema=None, dotpath=None):
#     meta = UserMeta(document=document,
#                     fields=fields,
#                     exclude=exclude,
#                     formfield_callback=formfield_callback,
#                     schema=schema,
#                     dotpath=dotpath,)
#     class FactoryForm(form):
#         Meta = meta
#     
#     return FactoryForm


from django.forms.formsets import BaseFormSet, formset_factory
from django.utils.translation import ugettext_lazy as _, ugettext
from dockit.forms.forms import DocumentForm, documentform_factory
        return saved_instances

    def save_new_objects(self, commit=True):
        self.new_objects = []
        for form in self.extra_forms:
            if not form.has_changed():
                continue
            # If someone has marked an add form for deletion, don't save the
            # object.
            if self.can_delete and self._should_delete_form(form):
                continue
            self.new_objects.append(self.save_new(form, commit=commit))
            if not commit:
                self.saved_forms.append(form)
        return self.new_objects

    def add_fields(self, form, index):
        #CONSIDER there is no parent object, more like a document/instance and a dotpath
        """Add a hidden field for the object's primary key."""
        #TODO
        super(BaseDocumentFormSet, self).add_fields(form, index)

def documentformset_factory(document, form=DocumentForm, formfield_callback=None,
                         formset=BaseDocumentFormSet,
                         dotpath=None, schema=None,
                         extra=1, can_delete=False, can_order=False,
                         max_num=None, fields=None, exclude=None):
    """
    Returns a FormSet class for the given Document class.
    """

# Path: dockit/forms/forms.py
# class DocumentForm(BaseDocumentForm):
#     """ The document form object """
#     __metaclass__ = DocumentFormMetaClass
# 
# def documentform_factory(document, form=DocumentForm, fields=None, exclude=None,
#                              formfield_callback=None, schema=None, dotpath=None):
#     meta = UserMeta(document=document,
#                     fields=fields,
#                     exclude=exclude,
#                     formfield_callback=formfield_callback,
#                     schema=schema,
#                     dotpath=dotpath,)
#     class FactoryForm(form):
#         Meta = meta
#     
#     return FactoryForm


# Path: dockit/forms/formsets.py
from django.forms.formsets import BaseFormSet, formset_factory
from django.utils.translation import ugettext_lazy as _, ugettext
from dockit.forms.forms import DocumentForm, documentform_factory

        return saved_instances

    def save_new_objects(self, commit=True):
        self.new_objects = []
        for form in self.extra_forms:
            if not form.has_changed():
                continue
            # If someone has marked an add form for deletion, don't save the
            # object.
            if self.can_delete and self._should_delete_form(form):
                continue
            self.new_objects.append(self.save_new(form, commit=commit))
            if not commit:
                self.saved_forms.append(form)
        return self.new_objects

    def add_fields(self, form, index):
        #CONSIDER there is no parent object, more like a document/instance and a dotpath
        """Add a hidden field for the object's primary key."""
        #TODO
        super(BaseDocumentFormSet, self).add_fields(form, index)

def documentformset_factory(document, form=DocumentForm, formfield_callback=None,
                         formset=BaseDocumentFormSet,
                         dotpath=None, schema=None,
                         extra=1, can_delete=False, can_order=False,
                         max_num=None, fields=None, exclude=None):
    """
    Returns a FormSet class for the given Document class.
    """

    form = documentform_factory(document, form=form, fields=fields, exclude=exclude,