|
| 1 | +# $Id: dbinit.py,v 1.1 2001-07-23 23:28:43 richard Exp $ |
| 2 | + |
| 3 | +import os |
| 4 | + |
| 5 | +import instance_config |
| 6 | +from roundup import roundupdb, cgi_client, mailgw |
| 7 | +import select_db |
| 8 | +from roundup.roundupdb import Class, FileClass |
| 9 | + |
| 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 |
| 16 | + |
| 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 |
| 23 | + |
| 24 | + |
| 25 | +def open(name=None): |
| 26 | + ''' as from the roundupdb method openDB |
| 27 | + |
| 28 | + ''' |
| 29 | + from roundup.hyperdb import String, Date, Link, Multilink |
| 30 | + |
| 31 | + # open the database |
| 32 | + db = Database(instance_config.DATABASE, name) |
| 33 | + |
| 34 | + # Now initialise the schema. Must do this each time. |
| 35 | + pri = Class(db, "priority", |
| 36 | + name=String(), order=String()) |
| 37 | + pri.setkey("name") |
| 38 | + |
| 39 | + stat = Class(db, "status", |
| 40 | + name=String(), order=String()) |
| 41 | + stat.setkey("name") |
| 42 | + |
| 43 | + keywords = Class(db, "keyword", |
| 44 | + name=String()) |
| 45 | + |
| 46 | + user = Class(db, "user", |
| 47 | + username=String(), password=String(), |
| 48 | + address=String(), realname=String(), |
| 49 | + phone=String(), organisation=String()) |
| 50 | + user.setkey("username") |
| 51 | + |
| 52 | + msg = FileClass(db, "msg", |
| 53 | + author=Link("user"), recipients=Multilink("user"), |
| 54 | + date=Date(), summary=String(), |
| 55 | + files=Multilink("file")) |
| 56 | + |
| 57 | + file = FileClass(db, "file", |
| 58 | + name=String(), type=String()) |
| 59 | + |
| 60 | + keyword = Class(db, "keyword", name=String()) |
| 61 | + keyword.setkey("name") |
| 62 | + |
| 63 | + issue = IssueClass(db, "issue", |
| 64 | + assignedto=Link("user"), topic=hyperdb.Multilink("keyword"), |
| 65 | + priority=Link("priority"), status=Link("status")) |
| 66 | + issue.setkey('title') |
| 67 | + |
| 68 | + import detectors |
| 69 | + detectors.init(db) |
| 70 | + |
| 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. |
| 77 | +
|
| 78 | + ''' |
| 79 | + dbdir = os.path.join(instance_config.DATABASE, 'files') |
| 80 | + if not os.path.isdir(dbdir): |
| 81 | + os.makedirs(dbdir) |
| 82 | + |
| 83 | + db = open("admin") |
| 84 | + db.clear() |
| 85 | + |
| 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") |
| 92 | + |
| 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") |
| 102 | + |
| 103 | + user = db.getclass('user') |
| 104 | + user.create(username="admin", password=adminpw, |
| 105 | + address=instance_config.ADMIN_EMAIL) |
| 106 | + |
| 107 | + db.close() |
| 108 | + |
| 109 | +# |
| 110 | +# $Log: not supported by cvs2svn $ |
| 111 | +# Revision 1.4 2001/07/23 08:45:28 richard |
| 112 | +# ok, so now "./roundup-admin init" will ask questions in an attempt to get a |
| 113 | +# workable instance_home set up :) |
| 114 | +# _and_ anydbm has had its first test :) |
| 115 | +# |
| 116 | +# Revision 1.3 2001/07/23 07:14:41 richard |
| 117 | +# Moved the database backends off into backends. |
| 118 | +# |
| 119 | +# Revision 1.2 2001/07/23 06:25:50 richard |
| 120 | +# relfected the move to roundup/backends |
| 121 | +# |
| 122 | +# Revision 1.1 2001/07/23 04:33:21 anthonybaxter |
| 123 | +# split __init__.py into 2. dbinit and instance_config. |
| 124 | +# |
| 125 | +# Revision 1.1 2001/07/23 03:50:46 anthonybaxter |
| 126 | +# moved templates to proper location |
| 127 | +# |
| 128 | +# Revision 1.2 2001/07/22 12:09:32 richard |
| 129 | +# Final commit of Grande Splite |
| 130 | +# |
| 131 | +# |
| 132 | + |
| 133 | + |
0 commit comments