Code

Roundupdb now appends "mailing list" information to its messages which
[roundup.git] / roundup / templates / classic / dbinit.py
1 # $Id: dbinit.py,v 1.5 2001-08-02 06:38:17 richard Exp $
3 import os
5 import instance_config
6 from roundup import roundupdb, cgi_client, mailgw 
7 import select_db
9 from roundup.roundupdb import Class, FileClass
11 class Database(roundupdb.Database, select_db.Database):
12     ''' Creates a hybrid database from: 
13          . the selected database back-end from select_db
14          . the roundup extensions from roundupdb 
15     ''' 
16     pass 
18 class IssueClass(roundupdb.IssueClass):
19     ''' issues need the email information
20     '''
21     ISSUE_TRACKER_WEB = instance_config.ISSUE_TRACKER_WEB
22     ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
23     ADMIN_EMAIL = instance_config.ADMIN_EMAIL
24     MAILHOST = instance_config.MAILHOST
26  
27 def open(name=None):
28     ''' as from the roundupdb method openDB 
29  
30     ''' 
31     from roundup.hyperdb import String, Date, Link, Multilink
33     # open the database
34     db = Database(instance_config.DATABASE, name)
36     # Now initialise the schema. Must do this each time.
37     pri = Class(db, "priority", 
38                     name=String(), order=String())
39     pri.setkey("name")
41     stat = Class(db, "status", 
42                     name=String(), order=String())
43     stat.setkey("name")
45     keyword = Class(db, "keyword", 
46                     name=String())
47     keyword.setkey("name")
49     user = Class(db, "user", 
50                     username=String(),   password=String(),
51                     address=String(),    realname=String(), 
52                     phone=String(),      organisation=String())
53     user.setkey("username")
55     msg = FileClass(db, "msg", 
56                     author=Link("user"), recipients=Multilink("user"), 
57                     date=Date(),         summary=String(), 
58                     files=Multilink("file"))
60     file = FileClass(db, "file", 
61                     name=String(),       type=String())
63     issue = IssueClass(db, "issue", 
64                     assignedto=Link("user"), topic=Multilink("keyword"),
65                     priority=Link("priority"), status=Link("status"))
66     issue.setkey('title')
68     import detectors
69     detectors.init(db)
71     return db
72  
73 def init(adminpw): 
74     ''' as from the roundupdb method initDB 
75  
76     Open the new database, and set up a bunch of attributes.
78     ''' 
79     dbdir = os.path.join(instance_config.DATABASE, 'files')
80     if not os.path.isdir(dbdir):
81         os.makedirs(dbdir)
83     db = open("admin")
84     db.clear()
86     pri = db.getclass('priority')
87     pri.create(name="critical", order="1")
88     pri.create(name="urgent", order="2")
89     pri.create(name="bug", order="3")
90     pri.create(name="feature", order="4")
91     pri.create(name="wish", order="5")
93     stat = db.getclass('status')
94     stat.create(name="unread", order="1")
95     stat.create(name="deferred", order="2")
96     stat.create(name="chatting", order="3")
97     stat.create(name="need-eg", order="4")
98     stat.create(name="in-progress", order="5")
99     stat.create(name="testing", order="6")
100     stat.create(name="done-cbb", order="7")
101     stat.create(name="resolved", order="8")
103     user = db.getclass('user')
104     user.create(username="admin", password=adminpw, 
105                                   address=instance_config.ADMIN_EMAIL)
107     db.close()
110 # $Log: not supported by cvs2svn $
111 # Revision 1.4  2001/07/29 07:01:39  richard
112 # Added vim command to all source so that we don't get no steenkin' tabs :)
114 # Revision 1.3  2001/07/24 10:46:22  anthonybaxter
115 # Added templatebuilder module. two functions - one to pack up the html base,
116 # one to unpack it. Packed up the two standard templates into htmlbases.
117 # Modified __init__ to install them.
119 # __init__.py magic was needed for the rather high levels of wierd import magic.
120 # Reducing level of import magic == (good, future)
122 # Revision 1.2  2001/07/24 01:06:43  richard
123 # Oops - accidentally duped the keywords class
125 # Revision 1.1  2001/07/23 23:28:43  richard
126 # Adding the classic template
128 # Revision 1.4  2001/07/23 08:45:28  richard
129 # ok, so now "./roundup-admin init" will ask questions in an attempt to get a
130 # workable instance_home set up :)
131 # _and_ anydbm has had its first test :)
133 # Revision 1.3  2001/07/23 07:14:41  richard
134 # Moved the database backends off into backends.
136 # Revision 1.2  2001/07/23 06:25:50  richard
137 # relfected the move to roundup/backends
139 # Revision 1.1  2001/07/23 04:33:21  anthonybaxter
140 # split __init__.py into 2. dbinit and instance_config.
142 # Revision 1.1  2001/07/23 03:50:46  anthonybaxter
143 # moved templates to proper location
145 # Revision 1.2  2001/07/22 12:09:32  richard
146 # Final commit of Grande Splite
149 # vim: set filetype=python ts=4 sw=4 et si