# -*- coding: UTF-8 -*-
#
# Copyright (C) 2007 by Jan Dittberner.
#
# 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.
#
# Version: $Id: client.py 1101 2007-02-28 21:15:20Z jan $

from sqlalchemy import *
from tables import domain_table
from gnuviechadmin.exceptions import *

import record
from BackendEntity import *
from BackendEntityHandler import *

class Domain(BackendEntity):
    """Entity class for DNS domains."""

    _shortkeys = ("domainid", "sysuserid", "name", "type")

    def __init__(self, verbose = False, **kwargs):
        BackendEntity.__init__(self, verbose)
        self.domainid = None
        self.sysuserid = None
        self.name = None
        self.type = None
        self.validate()

domain_mapper = mapper(Domain, domain_table)
domain_mapper.add_property("records", relation(record.Record))

class DomainHandler(BackendEntityHandler):
    """BackendEntityHandler for Domain entities."""

    def __init__(self, verbose = False):
        BackendEntityHandler.__init__(self, Domain, verbose)