Code

stupid typo
[roundup.git] / roundup / templates / classic / dbinit.py
1 #
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
3 # This module is free software, and you may redistribute it and/or modify
4 # under the same terms as Python, so long as this copyright message and
5 # disclaimer are retained in their original form.
6 #
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
10 # POSSIBILITY OF SUCH DAMAGE.
11 #
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17
18 # $Id: dbinit.py,v 1.7 2001-08-07 00:24:43 richard Exp $
20 import os
22 import instance_config
23 from roundup import roundupdb, cgi_client, mailgw 
24 import select_db
26 from roundup.roundupdb import Class, FileClass
28 class Database(roundupdb.Database, select_db.Database):
29     ''' Creates a hybrid database from: 
30          . the selected database back-end from select_db
31          . the roundup extensions from roundupdb 
32     ''' 
33     pass 
35 class IssueClass(roundupdb.IssueClass):
36     ''' issues need the email information
37     '''
38     ISSUE_TRACKER_WEB = instance_config.ISSUE_TRACKER_WEB
39     ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
40     ADMIN_EMAIL = instance_config.ADMIN_EMAIL
41     MAILHOST = instance_config.MAILHOST
43  
44 def open(name=None):
45     ''' as from the roundupdb method openDB 
46  
47     ''' 
48     from roundup.hyperdb import String, Date, Link, Multilink
50     # open the database
51     db = Database(instance_config.DATABASE, name)
53     # Now initialise the schema. Must do this each time.
54     pri = Class(db, "priority", 
55                     name=String(), order=String())
56     pri.setkey("name")
58     stat = Class(db, "status", 
59                     name=String(), order=String())
60     stat.setkey("name")
62     keyword = Class(db, "keyword", 
63                     name=String())
64     keyword.setkey("name")
66     user = Class(db, "user", 
67                     username=String(),   password=String(),
68                     address=String(),    realname=String(), 
69                     phone=String(),      organisation=String())
70     user.setkey("username")
72     msg = FileClass(db, "msg", 
73                     author=Link("user"), recipients=Multilink("user"), 
74                     date=Date(),         summary=String(), 
75                     files=Multilink("file"))
77     file = FileClass(db, "file", 
78                     name=String(),       type=String())
80     issue = IssueClass(db, "issue", 
81                     assignedto=Link("user"), topic=Multilink("keyword"),
82                     priority=Link("priority"), status=Link("status"))
83     issue.setkey('title')
85     import detectors
86     detectors.init(db)
88     return db
89  
90 def init(adminpw): 
91     ''' as from the roundupdb method initDB 
92  
93     Open the new database, and set up a bunch of attributes.
95     ''' 
96     dbdir = os.path.join(instance_config.DATABASE, 'files')
97     if not os.path.isdir(dbdir):
98         os.makedirs(dbdir)
100     db = open("admin")
101     db.clear()
103     pri = db.getclass('priority')
104     pri.create(name="critical", order="1")
105     pri.create(name="urgent", order="2")
106     pri.create(name="bug", order="3")
107     pri.create(name="feature", order="4")
108     pri.create(name="wish", order="5")
110     stat = db.getclass('status')
111     stat.create(name="unread", order="1")
112     stat.create(name="deferred", order="2")
113     stat.create(name="chatting", order="3")
114     stat.create(name="need-eg", order="4")
115     stat.create(name="in-progress", order="5")
116     stat.create(name="testing", order="6")
117     stat.create(name="done-cbb", order="7")
118     stat.create(name="resolved", order="8")
120     user = db.getclass('user')
121     user.create(username="admin", password=adminpw, 
122                                   address=instance_config.ADMIN_EMAIL)
124     db.close()
127 # $Log: not supported by cvs2svn $
128 # Revision 1.6  2001/08/07 00:15:51  richard
129 # Added the copyright/license notice to (nearly) all files at request of
130 # Bizar Software.
132 # Revision 1.5  2001/08/02 06:38:17  richard
133 # Roundupdb now appends "mailing list" information to its messages which
134 # include the e-mail address and web interface address. Templates may
135 # override this in their db classes to include specific information (support
136 # instructions, etc).
138 # Revision 1.4  2001/07/29 07:01:39  richard
139 # Added vim command to all source so that we don't get no steenkin' tabs :)
141 # Revision 1.3  2001/07/24 10:46:22  anthonybaxter
142 # Added templatebuilder module. two functions - one to pack up the html base,
143 # one to unpack it. Packed up the two standard templates into htmlbases.
144 # Modified __init__ to install them.
146 # __init__.py magic was needed for the rather high levels of wierd import magic.
147 # Reducing level of import magic == (good, future)
149 # Revision 1.2  2001/07/24 01:06:43  richard
150 # Oops - accidentally duped the keywords class
152 # Revision 1.1  2001/07/23 23:28:43  richard
153 # Adding the classic template
155 # Revision 1.4  2001/07/23 08:45:28  richard
156 # ok, so now "./roundup-admin init" will ask questions in an attempt to get a
157 # workable instance_home set up :)
158 # _and_ anydbm has had its first test :)
160 # Revision 1.3  2001/07/23 07:14:41  richard
161 # Moved the database backends off into backends.
163 # Revision 1.2  2001/07/23 06:25:50  richard
164 # relfected the move to roundup/backends
166 # Revision 1.1  2001/07/23 04:33:21  anthonybaxter
167 # split __init__.py into 2. dbinit and instance_config.
169 # Revision 1.1  2001/07/23 03:50:46  anthonybaxter
170 # moved templates to proper location
172 # Revision 1.2  2001/07/22 12:09:32  richard
173 # Final commit of Grande Splite
176 # vim: set filetype=python ts=4 sw=4 et si