Exemple #1
0
 def delete(self):
     citation_handle = self.instance.handle
     with DbTxn(self._("Delete citation"), self.database) as transaction:
         for (item, handle) in self.database.find_backlink_handles(citation_handle):
             handle_func = self.database.get_table_func(item, "handle_func")
             commit_func = self.database.get_table_func(item, "commit_func")
             obj = handle_func(handle)
             obj.remove_handle_references('Citation', [citation_handle])
             commit_func(obj, transaction)
         self.database.remove_citation(self.instance.handle, transaction)
     self.handler.send_message(self._("Deleted citation. <a href='%s'>Undo</a>." % "FIXME"))
     self.handler.redirect(self.handler.app.make_url("/citation"))
Exemple #2
0
 def delete(self):
     tag_handle = self.instance.handle
     with DbTxn(self._("Delete tag"), self.database) as transaction:
         for (item,
              handle) in self.database.find_backlink_handles(tag_handle):
             handle_func = self.database.get_table_func(item, "handle_func")
             commit_func = self.database.get_table_func(item, "commit_func")
             obj = handle_func(handle)
             obj.remove_handle_references('Tag', [tag_handle])
             commit_func(obj, transaction)
         self.database.remove_tag(self.instance.handle, transaction)
     self.handler.send_message("Deleted tag. <a href='FIXME'>Undo</a>.")
     self.handler.redirect(self.handler.app.make_url("/tag"))
Exemple #3
0
 def delete(self):
     respository_handle = self.instance.handle
     with DbTxn(self._("Delete repository"), self.database) as transaction:
         for (item, handle
              ) in self.database.find_backlink_handles(respository_handle):
             handle_func = self.database.get_table_func(item, "handle_func")
             commit_func = self.database.get_table_func(item, "commit_func")
             obj = handle_func(handle)
             obj.remove_handle_references('Respository',
                                          [respository_handle])
             commit_func(obj, transaction)
         self.database.remove_repository(self.instance.handle, transaction)
     self.handler.send_message(
         self._("Deleted repository. <a href='%s'>Undo</a>." % "FIXME"))
     self.handler.redirect(self.handler.app.make_url("/repository"))
Exemple #4
0
def importData(db, filename, user):
    db.disable_signals()
    try:
        with DbTxn(_("JSON import"), db, batch=True) as trans:
            with OpenFileOrStdin(filename, encoding="utf-8") as fp:
                line = fp.readline()
                while line:
                    data = json.loads(line)
                    if data["_class"] == "Person":
                        obj = Person.from_struct(data)
                        db.add_person(obj, trans)
                    elif data["_class"] == "Family":
                        obj = Family.from_struct(data)
                        db.add_family(obj, trans)
                    elif data["_class"] == "Event":
                        obj = Event.from_struct(data)
                        db.add_event(obj, trans)
                    elif data["_class"] == "Media":
                        obj = Media.from_struct(data)
                        db.add_media(obj, trans)
                    elif data["_class"] == "Repository":
                        obj = Repository.from_struct(data)
                        db.add_repository(obj, trans)
                    elif data["_class"] == "Tag":
                        obj = Tag.from_struct(data)
                        db.add_tag(obj, trans)
                    elif data["_class"] == "Source":
                        obj = Source.from_struct(data)
                        db.add_source(obj, trans)
                    elif data["_class"] == "Citation":
                        obj = Citation.from_struct(data)
                        db.add_citation(obj, trans)
                    elif data["_class"] == "Note":
                        obj = Note.from_struct(data)
                        db.add_note(obj, trans)
                    elif data["_class"] == "Place":
                        obj = Place.from_struct(data)
                        db.add_place(obj, trans)
                    else:
                        LOG.warn("ignored: " + data)
                    line = fp.readline()
    except EnvironmentError as err:
        user.notify_error(_("%s could not be opened\n") % filename, str(err))

    db.enable_signals()
    db.request_rebuild()