Ejemplo n.º 1
0
 def register_collection(self):
     doc = DocumentDesign.get_document(
         self,
         virtual=False,
         verbose_name=self.title,
         collection=self.get_collection_name())
     force_register_documents(doc._meta.app_label, doc)
     return doc
Ejemplo n.º 2
0
 def test_force_register_documents(self):
     doc = create_document('testDocument', fields={'title':schema.CharField()})
     
     doc = create_document('testDocument', fields={'title':schema.CharField(), 'slug':schema.SlugField()})
     force_register_documents(doc._meta.app_label, doc)
     
     doc = get_base_document(doc._meta.collection)
     
     self.assertTrue('slug' in doc._meta.fields)
 def test_force_register_documents(self):
     doc = create_document('testDocument', fields={'title':schema.CharField()})
     
     doc = create_document('testDocument', fields={'title':schema.CharField(), 'slug':schema.SlugField()})
     force_register_documents(doc._meta.app_label, doc)
     
     doc = get_base_document(doc._meta.collection)
     
     self.assertTrue('slug' in doc._meta.fields)
Ejemplo n.º 4
0
    def register_collection(self):
        #create a base page document
        params = {
            'module': 'dockitcms.models.virtual',
            'virtual': False,
            'verbose_name': self.title,
            'collection': self.get_collection_name(),
            'parents': (BasePage, schema.Document),
            'name': self.get_schema_name(),
            'attrs': SortedDict(),
            'fields': SortedDict(),
            'typed_field': '_page_type',
        }
        if self.application:
            params['app_label'] = self.application.name
        params['attrs']['_collection_document'] = self

        base_doc = create_document(**params)
        force_register_documents(base_doc._meta.app_label, base_doc)
        base_doc.objects.index('path').commit()

        #loop through page_definitions and register them
        for page_def in self.page_definitions:
            params = {
                'parents': (base_doc,),
                'virtual': False,
                'typed_key': page_def.unique_id,
                'attrs': SortedDict([
                    ('_page_def', page_def),
                ])
            }
            page_def.get_document(**params)

        #CONSIDER: provide page defs defined in code
        for unique_id, page_schema in dict().items(): #REGISTERED_PAGE_DEFS.items()
            params = {
                'virtual': False,
                'typed_key': unique_id,
                'parents': (page_schema, base_doc),
                'name': '', #page_schema._meta.name,
                'fields': SortedDict(),
            }
            create_document(**params)

        return base_doc
Ejemplo n.º 5
0
 def register_collection(self):
     doc = DocumentDesign.get_document(self, virtual=False, verbose_name=self.title, collection=self.get_collection_name())
     force_register_documents(doc._meta.app_label, doc)
     return doc