# Path: gramps_connect/handlers/handlers.py
# class BaseHandler(tornado.web.RequestHandler):
#     def __init__(self, *args, **kwargs):
#         self.log = logging.getLogger(".Handler")
#         self.database = None
#         self.sitename = None
#         self.opts = None
#         for name in ["database", "sitename", "opts"]:
#             if name in kwargs:
#                 setattr(self, name, kwargs[name])
#                 del kwargs[name]
#         super().__init__(*args, **kwargs)
#         self._ = _
# 
#     def get_current_user(self):
#         return self.get_secure_cookie("user")
# 
#     def set_language(self, language):
#         if language == GrampsLocale.DEFAULT_TRANSLATION_STR:
#             language = None
#         locale = GrampsLocale(lang=language)
#         self._ = locale.translation.gettext
# 
#     def get_template_dict(self, **kwargs):
#         dict = {
#             "database": self.database,
#             "menu": [],
#             "action": "view",
#             "user": self.current_user,
#             "sitename": self.sitename,
#             "opts": self.opts,
#             "css_theme": "Web_Mainz.css",
#             "gramps_version": VERSION,
#             "messages": [],
#             "_": self._,
#             "next": self.get_argument("next", None),
#         }
#         dict.update(template_functions)
#         dict.update(kwargs)
#         return dict
# 
#     def get_form(self, table):
#         """
#         Return the proper form, give a table name.
#         """
#         from ..forms import PersonForm, FamilyForm
#         if table == "person":
#             form = PersonForm
#         elif table == "family":
#             form = FamilyForm
#         else:
#             raise Exception("invalid form")
#         return form
# 
# Path: gramps_connect/forms/personform.py
# class PersonForm(Form):
#     """
#     A form for listing, viewing, and editing a Person object.
#     """
#     _class = Person
#     view = "person"
#     tview = "People"
# 
#     # Fields for editor:
#     edit_fields = [
#         "primary_name.type",
#         "primary_name.title",
#         "primary_name.nick",
#         "primary_name.call",
#         "primary_name.first_name",
#         "primary_name.suffix",
#         "primary_name.surname_list.0.prefix",
#         "primary_name.surname_list.0.surname",
#         "primary_name.surname_list.0.origintype",
#         "gender",
#         "gramps_id",
#         "tag_list",
#         "private",
#     ]
# 
#     # URL for page view rows:
#     link = "/person/%(handle)s"
# 
#     # Search fields to use if not specified:
#     default_search_fields = [
#         "primary_name.surname_list.0.surname",
#         "primary_name.first_name",
#         # FIXME: add alternate names
#     ]
# 
#     # Search fields, list is OR
#     search_terms = {
#         "surname": "surname", 
#         "given": "given", 
#         "id": "gramps_id", 
#         "gender": "gender", 
#         "birth": "birth", 
#         "death": "death",
#     }
# 
#     order_by = [("surname", "ASC"), ("given", "ASC")]
# 
#     # Fields for page view; width sum = 95%:
#     select_fields = [
#         ("primary_name.surname_list.0.surname", 25),
#         ("primary_name.first_name", 20),
#         ("gramps_id", 10),
#         ("gender", 10),
#         ("birth_ref_index", 15),
#         ("death_ref_index", 15),
#     ]
# 
#     # Other fields needed to select:
#     env_fields = [
#         "handle",
#         "event_ref_list",
#     ]
# 
#     def probably_alive(self):
#         """
#         Placeholder for a probably_alive value.
#         """
#         return True


import tornado.web
from gramps.gen.utils.grampslocale import GrampsLocale, _
from .handlers import BaseHandler
from ..forms import PersonForm
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (c) 2015 Gramps Development Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#




class DeleteHandler(BaseHandler):
    @tornado.web.authenticated
    def get(self, table, handle):
        handle_func = self.database.get_table_func(table.title(),"handle_func")
        instance = handle_func(handle)

# Path: gramps_connect/handlers/handlers.py
# class BaseHandler(tornado.web.RequestHandler):
#     def __init__(self, *args, **kwargs):
#         self.log = logging.getLogger(".Handler")
#         self.database = None
#         self.sitename = None
#         self.opts = None
#         for name in ["database", "sitename", "opts"]:
#             if name in kwargs:
#                 setattr(self, name, kwargs[name])
#                 del kwargs[name]
#         super().__init__(*args, **kwargs)
#         self._ = _
# 
#     def get_current_user(self):
#         return self.get_secure_cookie("user")
# 
#     def set_language(self, language):
#         if language == GrampsLocale.DEFAULT_TRANSLATION_STR:
#             language = None
#         locale = GrampsLocale(lang=language)
#         self._ = locale.translation.gettext
# 
#     def get_template_dict(self, **kwargs):
#         dict = {
#             "database": self.database,
#             "menu": [],
#             "action": "view",
#             "user": self.current_user,
#             "sitename": self.sitename,
#             "opts": self.opts,
#             "css_theme": "Web_Mainz.css",
#             "gramps_version": VERSION,
#             "messages": [],
#             "_": self._,
#             "next": self.get_argument("next", None),
#         }
#         dict.update(template_functions)
#         dict.update(kwargs)
#         return dict
# 
#     def get_form(self, table):
#         """
#         Return the proper form, give a table name.
#         """
#         from ..forms import PersonForm, FamilyForm
#         if table == "person":
#             form = PersonForm
#         elif table == "family":
#             form = FamilyForm
#         else:
#             raise Exception("invalid form")
#         return form
# 
# Path: gramps_connect/forms/personform.py
# class PersonForm(Form):
#     """
#     A form for listing, viewing, and editing a Person object.
#     """
#     _class = Person
#     view = "person"
#     tview = "People"
# 
#     # Fields for editor:
#     edit_fields = [
#         "primary_name.type",
#         "primary_name.title",
#         "primary_name.nick",
#         "primary_name.call",
#         "primary_name.first_name",
#         "primary_name.suffix",
#         "primary_name.surname_list.0.prefix",
#         "primary_name.surname_list.0.surname",
#         "primary_name.surname_list.0.origintype",
#         "gender",
#         "gramps_id",
#         "tag_list",
#         "private",
#     ]
# 
#     # URL for page view rows:
#     link = "/person/%(handle)s"
# 
#     # Search fields to use if not specified:
#     default_search_fields = [
#         "primary_name.surname_list.0.surname",
#         "primary_name.first_name",
#         # FIXME: add alternate names
#     ]
# 
#     # Search fields, list is OR
#     search_terms = {
#         "surname": "surname", 
#         "given": "given", 
#         "id": "gramps_id", 
#         "gender": "gender", 
#         "birth": "birth", 
#         "death": "death",
#     }
# 
#     order_by = [("surname", "ASC"), ("given", "ASC")]
# 
#     # Fields for page view; width sum = 95%:
#     select_fields = [
#         ("primary_name.surname_list.0.surname", 25),
#         ("primary_name.first_name", 20),
#         ("gramps_id", 10),
#         ("gender", 10),
#         ("birth_ref_index", 15),
#         ("death_ref_index", 15),
#     ]
# 
#     # Other fields needed to select:
#     env_fields = [
#         "handle",
#         "event_ref_list",
#     ]
# 
#     def probably_alive(self):
#         """
#         Placeholder for a probably_alive value.
#         """
#         return True


# Path: gramps_connect/handlers/deletehandler.py
import tornado.web
from gramps.gen.utils.grampslocale import GrampsLocale, _
from .handlers import BaseHandler
from ..forms import PersonForm

#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (c) 2015 Gramps Development Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#




class DeleteHandler(BaseHandler):
    @tornado.web.authenticated
    def get(self, table, handle):
        handle_func = self.database.get_table_func(table.title(),"handle_func")
        instance = handle_func(handle)

        form_class = self.get_form(table)