Code

Added vim command to all source so that we don't get no steenkin' tabs :)
[roundup.git] / roundup / templates / classic / dbinit.py
1 # $Id: dbinit.py,v 1.4 2001-07-29 07:01:39 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_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
22     ADMIN_EMAIL = instance_config.ADMIN_EMAIL
23     MAILHOST = instance_config.MAILHOST
25  
26 def open(name=None):
27     ''' as from the roundupdb method openDB 
28  
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     keyword = Class(db, "keyword", 
45                     name=String())
46     keyword.setkey("name")
48     user = Class(db, "user", 
49                     username=String(),   password=String(),
50                     address=String(),    realname=String(), 
51                     phone=String(),      organisation=String())
52     user.setkey("username")
54     msg = FileClass(db, "msg", 
55                     author=Link("user"), recipients=Multilink("user"), 
56                     date=Date(),         summary=String(), 
57                     files=Multilink("file"))
59     file = FileClass(db, "file", 
60                     name=String(),       type=String())
62     issue = IssueClass(db, "issue", 
63                     assignedto=Link("user"), topic=Multilink("keyword"),
64                     priority=Link("priority"), status=Link("status"))
65     issue.setkey('title')
67     import detectors
68     detectors.init(db)
70     return db
71  
72 def init(adminpw): 
73     ''' as from the roundupdb method initDB 
74  
75     Open the new database, and set up a bunch of attributes.
77     ''' 
78     dbdir = os.path.join(instance_config.DATABASE, 'files')
79     if not os.path.isdir(dbdir):
80         os.makedirs(dbdir)
82     db = open("admin")
83     db.clear()
85     pri = db.getclass('priority')
86     pri.create(name="critical", order="1")
87     pri.create(name="urgent", order="2")
88     pri.create(name="bug", order="3")
89     pri.create(name="feature", order="4")
90     pri.create(name="wish", order="5")
92     stat = db.getclass('status')
93     stat.create(name="unread", order="1")
94     stat.create(name="deferred", order="2")
95     stat.create(name="chatting", order="3")
96     stat.create(name="need-eg", order="4")
97     stat.create(name="in-progress", order="5")
98     stat.create(name="testing", order="6")
99     stat.create(name="done-cbb", order="7")
100     stat.create(name="resolved", order="8")
102     user = db.getclass('user')
103     user.create(username="admin", password=adminpw, 
104                                   address=instance_config.ADMIN_EMAIL)
106     db.close()
109 # $Log: not supported by cvs2svn $
110 # Revision 1.3  2001/07/24 10:46:22  anthonybaxter
111 # Added templatebuilder module. two functions - one to pack up the html base,
112 # one to unpack it. Packed up the two standard templates into htmlbases.
113 # Modified __init__ to install them.
115 # __init__.py magic was needed for the rather high levels of wierd import magic.
116 # Reducing level of import magic == (good, future)
118 # Revision 1.2  2001/07/24 01:06:43  richard
119 # Oops - accidentally duped the keywords class
121 # Revision 1.1  2001/07/23 23:28:43  richard
122 # Adding the classic template
124 # Revision 1.4  2001/07/23 08:45:28  richard
125 # ok, so now "./roundup-admin init" will ask questions in an attempt to get a
126 # workable instance_home set up :)
127 # _and_ anydbm has had its first test :)
129 # Revision 1.3  2001/07/23 07:14:41  richard
130 # Moved the database backends off into backends.
132 # Revision 1.2  2001/07/23 06:25:50  richard
133 # relfected the move to roundup/backends
135 # Revision 1.1  2001/07/23 04:33:21  anthonybaxter
136 # split __init__.py into 2. dbinit and instance_config.
138 # Revision 1.1  2001/07/23 03:50:46  anthonybaxter
139 # moved templates to proper location
141 # Revision 1.2  2001/07/22 12:09:32  richard
142 # Final commit of Grande Splite
145 # vim: set filetype=python ts=4 sw=4 et si