Пример #1
0
    def save_root(self, root):
        r = Root()

        # rewirite primary fields
        r.author     = root.author
        r.date       = root.date
        r.repository = root.repository
        r.version    = root.version

        r.previous   = str(root.id)
        
        # copy sections for that root document
        for sec in root.sections:
            r.sections.append(self.save_section(LatestSection.objects(object_id = sec)[0], "old"))

        r.save()
Пример #2
0
    def to_database(self, source_file):
        # create root document
        r = Root()
        
        # load odml file using python-odml module
        odml_root = load(source_file)

        # rewrite root fields
        r.author     = odml_root.author
        r.date       = odml_root.date
        r.repository = odml_root.repository
        r.version    = odml_root.version

        r.previous   = None

        # add sections to 'section' ccollection
        for section in odml_root.sections:
            s = self._save_section(section, None)
            r.sections.append(s)

        # save new object in database
        r.save()