8a526e05ead8e19cd0d5ae9225a4f5254a559367
1 # $Id: dbinit.py,v 1.2 2001-07-23 06:25:50 richard Exp $
3 import instance_config
4 from roundup import hyperdb, backends.bsddb, roundupdb, cgi_client, mailgw
6 from roundup.roundupdb import Class, FileClass
7 import os
10 class Database(roundupdb.Database, backends.bsddb.Database):
11 ''' Creates a hybrid database from:
12 . the base Database class given in hyperdb (basic functionlity)
13 . the BSDDB implementation in hyperdb_bsddb
14 . the roundup extensions from roundupdb
15 '''
16 pass
18 class IssueClass(roundupdb.IssueClass):
19 ''' issues need the email information
20 '''
21 ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
22 ADMIN_EMAIL = instance_config.ADMIN_EMAIL
23 MAILHOST = instance_config.MAILHOST
26 class Client(cgi_client.Client):
27 ''' derives basic mail gateway implementation from the standard module,
28 with any specific extensions
29 '''
30 TEMPLATES = instance_config.TEMPLATES
31 pass
33 class MailGW(mailgw.MailGW):
34 ''' derives basic mail gateway implementation from the standard module,
35 with any specific extensions
36 '''
37 ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
38 ADMIN_EMAIL = instance_config.ADMIN_EMAIL
39 MAILHOST = instance_config.MAILHOST
41 def open(name=None):
42 ''' as from the roundupdb method openDB
44 storagelocator must be the directory the __init__.py file is in
45 - os.path.split(__file__)[0] gives us that I think
46 '''
47 from roundup.hyperdb import String, Date, Link, Multilink
49 # open the database
50 db = Database(instance_config.DATABASE, name)
52 # Now initialise the schema. Must do this each time.
53 pri = Class(db, "priority",
54 name=String(), order=String())
55 pri.setkey("name")
57 stat = Class(db, "status",
58 name=String(), order=String())
59 stat.setkey("name")
61 keywords = Class(db, "keyword",
62 name=String())
64 user = Class(db, "user",
65 username=String(), password=String(),
66 address=String(), realname=String(),
67 phone=String(), organisation=String())
68 user.setkey("username")
70 msg = FileClass(db, "msg",
71 author=Link("user"), recipients=Multilink("user"),
72 date=Date(), summary=String(),
73 files=Multilink("file"))
75 file = FileClass(db, "file",
76 name=String(), type=String())
78 # bugs and support calls etc
79 rate = Class(db, "rate",
80 name=String(), order=String())
81 rate.setkey("name")
83 source = Class(db, "source",
84 name=String(), order=String())
85 source.setkey("name")
87 platform = Class(db, "platform",
88 name=String(), order=String())
89 platform.setkey("name")
91 product = Class(db, "product",
92 name=String(), order=String())
93 product.setkey("name")
95 timelog = Class(db, "timelog",
96 date=Date(), time=String(),
97 performedby=Link("user"), description=String())
99 issue = IssueClass(db, "issue",
100 assignedto=Link("user"), priority=Link("priority"),
101 status=Link("status"), rate=Link("rate"),
102 source=Link("source"), product=Link("product"),
103 platform=Multilink("platform"), version=String(),
104 timelog=Multilink("timelog"), customername=String())
105 issue.setkey('title')
107 import detectors
108 detectors.init(db)
110 return db
112 def init(adminpw):
113 ''' as from the roundupdb method initDB
115 storagelocator must be the directory the __init__.py file is in
116 - os.path.split(__file__)[0] gives us that I think
118 Open the new database, and set up a bunch of attributes.
120 '''
121 dbdir = os.path.join(instance_config.DATABASE, 'files')
122 if not os.path.isdir(dbdir):
123 os.makedirs(dbdir)
125 db = open("admin")
126 db.clear()
128 pri = db.getclass('priority')
129 pri.create(name="fatal-bug", order="1")
130 pri.create(name="bug", order="2")
131 pri.create(name="usability", order="3")
132 pri.create(name="feature", order="4")
133 pri.create(name="support", order="5")
135 stat = db.getclass('status')
136 stat.create(name="unread", order="1")
137 stat.create(name="deferred", order="2")
138 stat.create(name="chatting", order="3")
139 stat.create(name="need-eg", order="4")
140 stat.create(name="in-progress", order="5")
141 stat.create(name="testing", order="6")
142 stat.create(name="done-cbb", order="7")
143 stat.create(name="resolved", order="8")
145 rate = db.getclass("rate")
146 rate.create(name='basic', order="1")
147 rate.create(name='premium', order="2")
148 rate.create(name='internal', order="3")
150 source = db.getclass("source")
151 source.create(name='phone', order="1")
152 source.create(name='e-mail', order="2")
153 source.create(name='internal', order="3")
154 source.create(name='internal-qa', order="4")
156 platform = db.getclass("platform")
157 platform.create(name='linux', order="1")
158 platform.create(name='windows', order="2")
159 platform.create(name='mac', order="3")
161 product = db.getclass("product")
162 product.create(name='Bizar Shop', order="1")
163 product.create(name='Bizar Shop Developer', order="2")
164 product.create(name='Bizar Shop Manual', order="3")
165 product.create(name='Bizar Shop Developer Manual', order="4")
167 user = db.getclass('user')
168 user.create(username="admin", password=adminpw,
169 address=instance_config.ADMIN_EMAIL)
171 db.close()
173 #
174 # $Log: not supported by cvs2svn $
175 # Revision 1.1 2001/07/23 04:33:21 anthonybaxter
176 # split __init__.py into 2. dbinit and instance_config.
177 #
178 # Revision 1.1 2001/07/23 03:50:46 anthonybaxter
179 # moved templates to proper location
180 #
181 # Revision 1.2 2001/07/22 12:09:32 richard
182 # Final commit of Grande Splite
183 #
184 #