1 # $Id: dbinit.py,v 1.9 2001-08-02 06:38:17 richard Exp $
3 import os
5 import instance_config
6 from roundup import roundupdb
7 import select_db
8 from roundup.roundupdb import Class, FileClass
10 class Database(roundupdb.Database, select_db.Database):
11 ''' Creates a hybrid database from:
12 . the selected database back-end from select_db
13 . the roundup extensions from roundupdb
14 '''
15 pass
17 class IssueClass(roundupdb.IssueClass):
18 ''' issues need the email information
19 '''
20 ISSUE_TRACKER_WEB = instance_config.ISSUE_TRACKER_WEB
21 ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
22 ADMIN_EMAIL = instance_config.ADMIN_EMAIL
23 MAILHOST = instance_config.MAILHOST
26 def open(name=None):
27 ''' as from the roundupdb method openDB
29 '''
30 from roundup.hyperdb import String, Date, Link, Multilink
32 # open the database
33 db = Database(instance_config.DATABASE, name)
35 # Now initialise the schema. Must do this each time.
36 pri = Class(db, "priority",
37 name=String(), order=String())
38 pri.setkey("name")
40 stat = Class(db, "status",
41 name=String(), order=String())
42 stat.setkey("name")
44 keywords = Class(db, "keyword",
45 name=String())
47 user = Class(db, "user",
48 username=String(), password=String(),
49 address=String(), realname=String(),
50 phone=String(), organisation=String())
51 user.setkey("username")
53 msg = FileClass(db, "msg",
54 author=Link("user"), recipients=Multilink("user"),
55 date=Date(), summary=String(),
56 files=Multilink("file"))
58 file = FileClass(db, "file",
59 name=String(), type=String())
61 # bugs and support calls etc
62 rate = Class(db, "rate",
63 name=String(), order=String())
64 rate.setkey("name")
66 source = Class(db, "source",
67 name=String(), order=String())
68 source.setkey("name")
70 platform = Class(db, "platform",
71 name=String(), order=String())
72 platform.setkey("name")
74 product = Class(db, "product",
75 name=String(), order=String())
76 product.setkey("name")
78 timelog = Class(db, "timelog",
79 date=Date(), time=String(),
80 performedby=Link("user"), description=String())
82 support = IssueClass(db, "support",
83 assignedto=Link("user"), status=Link("status"),
84 rate=Link("rate"), source=Link("source"),
85 product=Link("product"), platform=Multilink("platform"),
86 version=String(), timelog=Multilink("timelog"),
87 customername=String())
89 issue = IssueClass(db, "issue",
90 assignedto=Link("user"), priority=Link("priority"),
91 status=Link("status"), product=Link("product"),
92 platform=Multilink("platform"), version=String(),
93 supportcall=Multilink("support"))
95 import detectors
96 detectors.init(db)
98 return db
100 def init(adminpw):
101 ''' as from the roundupdb method initDB
103 Open the new database, and set up a bunch of attributes.
105 '''
106 dbdir = os.path.join(instance_config.DATABASE, 'files')
107 if not os.path.isdir(dbdir):
108 os.makedirs(dbdir)
110 db = open("admin")
111 db.clear()
113 pri = db.getclass('priority')
114 pri.create(name="fatal-bug", order="1")
115 pri.create(name="bug", order="2")
116 pri.create(name="usability", order="3")
117 pri.create(name="feature", order="4")
119 stat = db.getclass('status')
120 stat.create(name="unread", order="1")
121 stat.create(name="deferred", order="2")
122 stat.create(name="chatting", order="3")
123 stat.create(name="need-eg", order="4")
124 stat.create(name="in-progress", order="5")
125 stat.create(name="testing", order="6")
126 stat.create(name="done-cbb", order="7")
127 stat.create(name="resolved", order="8")
129 rate = db.getclass("rate")
130 rate.create(name='basic', order="1")
131 rate.create(name='premium', order="2")
132 rate.create(name='internal', order="3")
134 source = db.getclass("source")
135 source.create(name='phone', order="1")
136 source.create(name='e-mail', order="2")
137 source.create(name='internal', order="3")
138 source.create(name='internal-qa', order="4")
140 platform = db.getclass("platform")
141 platform.create(name='linux', order="1")
142 platform.create(name='windows', order="2")
143 platform.create(name='mac', order="3")
145 product = db.getclass("product")
146 product.create(name='Bizar Shop', order="1")
147 product.create(name='Bizar Shop Developer', order="2")
148 product.create(name='Bizar Shop Manual', order="3")
149 product.create(name='Bizar Shop Developer Manual', order="4")
151 user = db.getclass('user')
152 user.create(username="admin", password=adminpw,
153 address=instance_config.ADMIN_EMAIL)
155 db.close()
157 #
158 # $Log: not supported by cvs2svn $
159 # Revision 1.8 2001/07/30 01:26:59 richard
160 # Big changes:
161 # . split off the support priority into its own class
162 # . added "new support, new user" to the page head
163 # . fixed the display options for the heading links
164 #
165 # Revision 1.7 2001/07/29 07:01:39 richard
166 # Added vim command to all source so that we don't get no steenkin' tabs :)
167 #
168 # Revision 1.6 2001/07/25 01:23:07 richard
169 # Added the Roundup spec to the new documentation directory.
170 #
171 # Revision 1.5 2001/07/23 23:20:35 richard
172 # forgot to remove the interfaces from the dbinit module ;)
173 #
174 # Revision 1.4 2001/07/23 08:45:28 richard
175 # ok, so now "./roundup-admin init" will ask questions in an attempt to get a
176 # workable instance_home set up :)
177 # _and_ anydbm has had its first test :)
178 #
179 # Revision 1.3 2001/07/23 07:14:41 richard
180 # Moved the database backends off into backends.
181 #
182 # Revision 1.2 2001/07/23 06:25:50 richard
183 # relfected the move to roundup/backends
184 #
185 # Revision 1.1 2001/07/23 04:33:21 anthonybaxter
186 # split __init__.py into 2. dbinit and instance_config.
187 #
188 # Revision 1.1 2001/07/23 03:50:46 anthonybaxter
189 # moved templates to proper location
190 #
191 # Revision 1.2 2001/07/22 12:09:32 richard
192 # Final commit of Grande Splite
193 #
194 #
195 # vim: set filetype=python ts=4 sw=4 et si