1
0
Fork 0

- updated schema

- use database connection


git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@186 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
Jan Dittberner 2006-04-17 20:24:38 +00:00
parent bca6369b41
commit f5e5b1ed34
3 changed files with 128 additions and 101 deletions

View file

@ -5,6 +5,8 @@
#
from SessionManager import *
from DomainManager import *
import Settings
import psycopg
class ServiceFacade:
"""
@ -12,8 +14,9 @@ class ServiceFacade:
gnuviech admin backend.
"""
def __init__(self):
self.sessionManager = SessionManager(None)
self.domainManager = DomainManager(None)
dbconn = psycopg.connect('host=%(dbhost)s user=%(dbuser)s password=%(dbpassword)s dbname=%(dbname)s' % Settings.DBSETTINGS)
self.sessionManager = SessionManager(dbconn)
self.domainManager = DomainManager(dbconn)
def _dispatch(self, method, params):
try:

View file

@ -5,9 +5,11 @@
#
ALLPREFIX = '/home/jan/gnvadmtest'
DBSETTINGS = { 'dbuser': 'exim4',
'dbpassword' : 'CotOgigmeIk5',
DBSETTINGS = { 'dbhost' : 'localhost',
'dbuser' : 'gnuviech',
'dbpassword' : 'SIKKnsyXsV5yU',
'dbname' : 'gnuviechadmin' }
# exim:CotOgigmeIk5
# courier:jevhi3Wriav
# gnuviech:SIKKnsyXsV5yU

View file

@ -1,155 +1,177 @@
--
-- Database Schema for gnuviechadmin-tools
-- (c) 2006 Jan Dittberner <jan@dittberner.info>
-- $Id$
-- PostgreSQL database dump
--
SET client_encoding = 'SQL_ASCII';
SET client_encoding = 'UNICODE';
SET check_function_bodies = false;
SET SESSION AUTHORIZATION 'postgres';
BEGIN;
--
-- Country names
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO PUBLIC;
SET SESSION AUTHORIZATION 'gnuviech';
SET search_path = public, pg_catalog;
--
-- Name: country; Type: TABLE; Schema: public; Owner: gnuviech
--
CREATE TABLE country (
countryid serial NOT NULL,
name varchar(40) NOT NULL,
PRIMARY KEY (countryid)
countryid serial PRIMARY KEY,
name character varying(40) NOT NULL
);
REVOKE ALL ON TABLE country FROM PUBLIC;
--
-- Salutations
-- Name: reseller; Type: TABLE; Schema: public; Owner: gnuviech
--
CREATE TABLE salutation (
salutationid serial NOT NULL,
name varchar(20) NOT NULL,
primary key (salutationid),
unique (name)
CREATE TABLE reseller (
resellerid serial PRIMARY KEY,
name character varying(40) NOT NULL
);
REVOKE ALL ON TABLE salutation FROM PUBLIC;
REVOKE ALL ON TABLE reseller FROM PUBLIC;
--
-- Client data
-- Name: client; Type: TABLE; Schema: public; Owner: gnuviech
--
CREATE TABLE client (
clientid serial NOT NULL,
clientnr varchar(10) NOT NULL,
salutationid integer NOT NULL REFERENCES salutation(salutationid),
firstname varchar(40) NOT NULL,
lastname varchar(40) NOT NULL,
address1 varchar(40) NOT NULL,
address2 varchar(40),
clientid serial PRIMARY KEY,
firstname character varying(40) NOT NULL,
lastname character varying(40) NOT NULL,
address1 character varying(40) NOT NULL,
address2 character varying(40),
countryid integer NOT NULL REFERENCES country(countryid),
town varchar(50) NOT NULL,
town character varying(50) NOT NULL,
zipcode character(5) NOT NULL,
state varchar(40),
state character varying(40),
active boolean DEFAULT false NOT NULL,
phone varchar(20),
mobile varchar(20),
reseller_id integer REFERENCES client(clientid),
organisation varchar(200),
primary key (clientid),
unique (clientnr)
phone character varying(20),
mobile character varying(20),
reseller_id integer REFERENCES reseller(resellerid),
organisation character varying(200)
);
REVOKE ALL ON TABLE client FROM PUBLIC;
--
-- Email addresses
-- Name: email; Type: TABLE; Schema: public; Owner: gnuviech
--
CREATE TABLE email (
emailid serial NOT NULL,
email varchar(128) NOT NULL,
emailid serial PRIMARY KEY,
email character varying(128) NOT NULL,
clientid integer NOT NULL REFERENCES client(clientid),
verified boolean DEFAULT false NOT NULL,
sortorder integer NOT NULL,
primary key (emailid),
unique (email),
unique (clientid, sortorder)
verified boolean DEFAULT false NOT NULL
);
REVOKE ALL ON TABLE email FROM PUBLIC;
--
-- System user to client mapping
-- Name: sysuser; Type: TABLE; Schema: public; Owner: gnuviech
--
CREATE TABLE sysuser (
sysuserid serial NOT NULL,
name varchar(12) NOT NULL,
sysuserid serial PRIMARY KEY,
name character varying(12) NOT NULL,
"type" integer DEFAULT 0 NOT NULL,
home varchar(128),
home character varying(128),
shell boolean,
"password" varchar(64),
"password" character varying(64),
clientid integer NOT NULL REFERENCES client(clientid),
toupdate boolean DEFAULT false NOT NULL,
md5pass varchar(32),
sysuid integer,
primary key (sysuserid),
unique (name),
unique (sysuid)
md5pass character varying(32),
sysuid integer UNIQUE
);
CREATE INDEX sysuser_type_idx ON sysuser ("type");
REVOKE ALL ON TABLE sysuser FROM PUBLIC;
GRANT SELECT ON TABLE sysuser TO GROUP services;
--
-- Domains
-- Name: domain; Type: TABLE; Schema: public; Owner: gnuviech
--
CREATE TABLE "domain" (
domainid serial NOT NULL,
domainname varchar(64) NOT NULL,
domainid serial PRIMARY KEY,
domainname character varying(64) NOT NULL,
clientid integer NOT NULL REFERENCES client(clientid),
status integer DEFAULT 0 NOT NULL,
sysuserid integer NOT NULL REFERENCES sysuser(sysuserid),
primary key (domainid),
unique (domainname)
sysuserid integer NOT NULL REFERENCES sysuser(sysuserid)
);
REVOKE ALL ON TABLE "domain" FROM PUBLIC;
GRANT SELECT ON TABLE "domain" TO GROUP services;
--
-- DNS Zones
-- Name: zone; Type: TABLE; Schema: public; Owner: gnuviech
--
CREATE TABLE "zone" (
zoneid serial NOT NULL,
"domain" integer NOT NULL REFERENCES "domain"(domainid),
"type" varchar(5) NOT NULL,
zoneid serial PRIMARY KEY,
"domain" integer NOT NULL REFERENCES domain(domainid),
"type" character varying(5) NOT NULL,
ttl integer NOT NULL,
mxprio integer,
resource varchar(256),
toupdate boolean DEFAULT false NOT NULL,
primary key (zoneid)
resource character varying(256),
toupdate boolean DEFAULT false NOT NULL
);
REVOKE ALL ON TABLE "zone" FROM PUBLIC;
--
-- Mail passwords for pop3/imap accounts
-- Name: mailpasswd; Type: TABLE; Schema: public; Owner: gnuviech
--
CREATE TABLE mailpasswd (
id varchar(128) DEFAULT ''::varchar NOT NULL,
crypt varchar(128) DEFAULT ''::varchar NOT NULL,
clear varchar(128) DEFAULT ''::varchar NOT NULL,
name varchar(128) DEFAULT ''::varchar NOT NULL,
id character varying(128) NOT NULL,
crypt character varying(128) DEFAULT '' NOT NULL,
clear character varying(128) DEFAULT '' NOT NULL,
name character varying(128) DEFAULT '' NOT NULL,
uid integer DEFAULT 65534 NOT NULL,
gid integer DEFAULT 65534 NOT NULL,
home varchar(255) DEFAULT ''::varchar NOT NULL,
maildir varchar(255) DEFAULT ''::varchar NOT NULL,
defaultdelivery varchar(255) DEFAULT ''::varchar NOT NULL,
quota varchar(255) DEFAULT ''::varchar NOT NULL,
home character varying(255) DEFAULT '' NOT NULL,
maildir character varying(255) DEFAULT '' NOT NULL,
defaultdelivery character varying(255) DEFAULT '' NOT NULL,
quota character varying(255) DEFAULT '' NOT NULL,
spamcheck boolean DEFAULT false NOT NULL,
sajunkscore integer,
primary key (id)
sajunkscore integer
);
REVOKE ALL ON TABLE mailpasswd FROM PUBLIC;
GRANT SELECT ON TABLE mailpasswd TO GROUP services;
GRANT ALL ON TABLE mailpasswd TO GROUP services;
--
-- Mail aliases for forwarding configuration and pop3/imap inbox mapping
-- Name: mailalias; Type: TABLE; Schema: public; Owner: gnuviech
--
CREATE TABLE mailalias (
email varchar(255) NOT NULL,
"domain" varchar(255) NOT NULL,
target varchar(255) NOT NULL,
primary key (email, "domain")
email character varying(255) NOT NULL,
"domain" character varying(255) NOT NULL,
target character varying(255) NOT NULL
);
REVOKE ALL ON TABLE mailalias FROM PUBLIC;
GRANT SELECT ON TABLE mailalias TO GROUP services;
GRANT ALL ON TABLE mailalias TO GROUP services;
--
-- Name: country; Type: TABLE DATA; Schema: public; Owner: gnuviech
--
INSERT INTO country (countryid, name) VALUES (1, 'Deutschland');
INSERT INTO country (countryid, name) VALUES (2, 'Schweiz');
INSERT INTO country (countryid, name) VALUES (3, 'Österreich');
SET SESSION AUTHORIZATION 'postgres';
COMMIT;