a677082becc9a4b06a20a31d93f1b3fe577d3ffe
1 # $Id: dbinit.py,v 1.4 2001-07-23 08:45:28 richard Exp $
3 import os
5 import instance_config
6 from roundup import roundupdb, cgi_client, mailgw
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_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
21 ADMIN_EMAIL = instance_config.ADMIN_EMAIL
22 MAILHOST = instance_config.MAILHOST
25 class Client(cgi_client.Client):
26 ''' derives basic mail gateway implementation from the standard module,
27 with any specific extensions
28 '''
29 TEMPLATES = instance_config.TEMPLATES
30 pass
32 class MailGW(mailgw.MailGW):
33 ''' derives basic mail gateway implementation from the standard module,
34 with any specific extensions
35 '''
36 ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
37 ADMIN_EMAIL = instance_config.ADMIN_EMAIL
38 MAILHOST = instance_config.MAILHOST
40 def open(name=None):
41 ''' as from the roundupdb method openDB
43 storagelocator must be the directory the __init__.py file is in
44 - os.path.split(__file__)[0] gives us that I think
45 '''
46 from roundup.hyperdb import String, Date, Link, Multilink
48 # open the database
49 db = Database(instance_config.DATABASE, name)
51 # Now initialise the schema. Must do this each time.
52 pri = Class(db, "priority",
53 name=String(), order=String())
54 pri.setkey("name")
56 stat = Class(db, "status",
57 name=String(), order=String())
58 stat.setkey("name")
60 keywords = Class(db, "keyword",
61 name=String())
63 user = Class(db, "user",
64 username=String(), password=String(),
65 address=String(), realname=String(),
66 phone=String(), organisation=String())
67 user.setkey("username")
69 msg = FileClass(db, "msg",
70 author=Link("user"), recipients=Multilink("user"),
71 date=Date(), summary=String(),
72 files=Multilink("file"))
74 file = FileClass(db, "file",
75 name=String(), type=String())
77 # bugs and support calls etc
78 rate = Class(db, "rate",
79 name=String(), order=String())
80 rate.setkey("name")
82 source = Class(db, "source",
83 name=String(), order=String())
84 source.setkey("name")
86 platform = Class(db, "platform",
87 name=String(), order=String())
88 platform.setkey("name")
90 product = Class(db, "product",
91 name=String(), order=String())
92 product.setkey("name")
94 timelog = Class(db, "timelog",
95 date=Date(), time=String(),
96 performedby=Link("user"), description=String())
98 issue = IssueClass(db, "issue",
99 assignedto=Link("user"), priority=Link("priority"),
100 status=Link("status"), rate=Link("rate"),
101 source=Link("source"), product=Link("product"),
102 platform=Multilink("platform"), version=String(),
103 timelog=Multilink("timelog"), customername=String())
104 issue.setkey('title')
106 import detectors
107 detectors.init(db)
109 return db
111 def init(adminpw):
112 ''' as from the roundupdb method initDB
114 storagelocator must be the directory the __init__.py file is in
115 - os.path.split(__file__)[0] gives us that I think
117 Open the new database, and set up a bunch of attributes.
119 '''
120 dbdir = os.path.join(instance_config.DATABASE, 'files')
121 if not os.path.isdir(dbdir):
122 os.makedirs(dbdir)
124 db = open("admin")
125 db.clear()
127 pri = db.getclass('priority')
128 pri.create(name="fatal-bug", order="1")
129 pri.create(name="bug", order="2")
130 pri.create(name="usability", order="3")
131 pri.create(name="feature", order="4")
132 pri.create(name="support", order="5")
134 stat = db.getclass('status')
135 stat.create(name="unread", order="1")
136 stat.create(name="deferred", order="2")
137 stat.create(name="chatting", order="3")
138 stat.create(name="need-eg", order="4")
139 stat.create(name="in-progress", order="5")
140 stat.create(name="testing", order="6")
141 stat.create(name="done-cbb", order="7")
142 stat.create(name="resolved", order="8")
144 rate = db.getclass("rate")
145 rate.create(name='basic', order="1")
146 rate.create(name='premium', order="2")
147 rate.create(name='internal', order="3")
149 source = db.getclass("source")
150 source.create(name='phone', order="1")
151 source.create(name='e-mail', order="2")
152 source.create(name='internal', order="3")
153 source.create(name='internal-qa', order="4")
155 platform = db.getclass("platform")
156 platform.create(name='linux', order="1")
157 platform.create(name='windows', order="2")
158 platform.create(name='mac', order="3")
160 product = db.getclass("product")
161 product.create(name='Bizar Shop', order="1")
162 product.create(name='Bizar Shop Developer', order="2")
163 product.create(name='Bizar Shop Manual', order="3")
164 product.create(name='Bizar Shop Developer Manual', order="4")
166 user = db.getclass('user')
167 user.create(username="admin", password=adminpw,
168 address=instance_config.ADMIN_EMAIL)
170 db.close()
172 #
173 # $Log: not supported by cvs2svn $
174 # Revision 1.3 2001/07/23 07:14:41 richard
175 # Moved the database backends off into backends.
176 #
177 # Revision 1.2 2001/07/23 06:25:50 richard
178 # relfected the move to roundup/backends
179 #
180 # Revision 1.1 2001/07/23 04:33:21 anthonybaxter
181 # split __init__.py into 2. dbinit and instance_config.
182 #
183 # Revision 1.1 2001/07/23 03:50:46 anthonybaxter
184 # moved templates to proper location
185 #
186 # Revision 1.2 2001/07/22 12:09:32 richard
187 # Final commit of Grande Splite
188 #
189 #