Mercurial > p > roundup > code
comparison roundup/templates/extended/dbinit.py @ 36:41e49de57a85
split __init__.py into 2. dbinit and instance_config.
| author | Anthony Baxter <anthonybaxter@users.sourceforge.net> |
|---|---|
| date | Mon, 23 Jul 2001 04:33:21 +0000 |
| parents | |
| children | 4b9ecc926ad7 |
comparison
equal
deleted
inserted
replaced
| 35:16f733c676fc | 36:41e49de57a85 |
|---|---|
| 1 # $Id: dbinit.py,v 1.1 2001-07-23 04:33:21 anthonybaxter Exp $ | |
| 2 | |
| 3 import instance_config | |
| 4 from roundup import hyperdb, hyper_bsddb, roundupdb, cgi_client, mailgw | |
| 5 | |
| 6 from roundup.roundupdb import Class, FileClass | |
| 7 import os | |
| 8 | |
| 9 | |
| 10 class Database(roundupdb.Database, hyper_bsddb.Database): | |
| 11 ''' Creates a hybrid database from: | |
| 12 . the base Database class given in hyperdb (basic functionlity) | |
| 13 . the BSDDB implementation in hyperdb_bsddb | |
| 14 . the roundup extensions from roundupdb | |
| 15 ''' | |
| 16 pass | |
| 17 | |
| 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 | |
| 24 | |
| 25 | |
| 26 class Client(cgi_client.Client): | |
| 27 ''' derives basic mail gateway implementation from the standard module, | |
| 28 with any specific extensions | |
| 29 ''' | |
| 30 TEMPLATES = instance_config.TEMPLATES | |
| 31 pass | |
| 32 | |
| 33 class MailGW(mailgw.MailGW): | |
| 34 ''' derives basic mail gateway implementation from the standard module, | |
| 35 with any specific extensions | |
| 36 ''' | |
| 37 ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL | |
| 38 ADMIN_EMAIL = instance_config.ADMIN_EMAIL | |
| 39 MAILHOST = instance_config.MAILHOST | |
| 40 | |
| 41 def open(name=None): | |
| 42 ''' as from the roundupdb method openDB | |
| 43 | |
| 44 storagelocator must be the directory the __init__.py file is in | |
| 45 - os.path.split(__file__)[0] gives us that I think | |
| 46 ''' | |
| 47 from roundup.hyperdb import String, Date, Link, Multilink | |
| 48 | |
| 49 # open the database | |
| 50 db = Database(instance_config.DATABASE, name) | |
| 51 | |
| 52 # Now initialise the schema. Must do this each time. | |
| 53 pri = Class(db, "priority", | |
| 54 name=String(), order=String()) | |
| 55 pri.setkey("name") | |
| 56 | |
| 57 stat = Class(db, "status", | |
| 58 name=String(), order=String()) | |
| 59 stat.setkey("name") | |
| 60 | |
| 61 keywords = Class(db, "keyword", | |
| 62 name=String()) | |
| 63 | |
| 64 user = Class(db, "user", | |
| 65 username=String(), password=String(), | |
| 66 address=String(), realname=String(), | |
| 67 phone=String(), organisation=String()) | |
| 68 user.setkey("username") | |
| 69 | |
| 70 msg = FileClass(db, "msg", | |
| 71 author=Link("user"), recipients=Multilink("user"), | |
| 72 date=Date(), summary=String(), | |
| 73 files=Multilink("file")) | |
| 74 | |
| 75 file = FileClass(db, "file", | |
| 76 name=String(), type=String()) | |
| 77 | |
| 78 # bugs and support calls etc | |
| 79 rate = Class(db, "rate", | |
| 80 name=String(), order=String()) | |
| 81 rate.setkey("name") | |
| 82 | |
| 83 source = Class(db, "source", | |
| 84 name=String(), order=String()) | |
| 85 source.setkey("name") | |
| 86 | |
| 87 platform = Class(db, "platform", | |
| 88 name=String(), order=String()) | |
| 89 platform.setkey("name") | |
| 90 | |
| 91 product = Class(db, "product", | |
| 92 name=String(), order=String()) | |
| 93 product.setkey("name") | |
| 94 | |
| 95 timelog = Class(db, "timelog", | |
| 96 date=Date(), time=String(), | |
| 97 performedby=Link("user"), description=String()) | |
| 98 | |
| 99 issue = IssueClass(db, "issue", | |
| 100 assignedto=Link("user"), priority=Link("priority"), | |
| 101 status=Link("status"), rate=Link("rate"), | |
| 102 source=Link("source"), product=Link("product"), | |
| 103 platform=Multilink("platform"), version=String(), | |
| 104 timelog=Multilink("timelog"), customername=String()) | |
| 105 issue.setkey('title') | |
| 106 | |
| 107 import detectors | |
| 108 detectors.init(db) | |
| 109 | |
| 110 return db | |
| 111 | |
| 112 def init(adminpw): | |
| 113 ''' as from the roundupdb method initDB | |
| 114 | |
| 115 storagelocator must be the directory the __init__.py file is in | |
| 116 - os.path.split(__file__)[0] gives us that I think | |
| 117 | |
| 118 Open the new database, and set up a bunch of attributes. | |
| 119 | |
| 120 ''' | |
| 121 dbdir = os.path.join(instance_config.DATABASE, 'files') | |
| 122 if not os.path.isdir(dbdir): | |
| 123 os.makedirs(dbdir) | |
| 124 | |
| 125 db = open("admin") | |
| 126 db.clear() | |
| 127 | |
| 128 pri = db.getclass('priority') | |
| 129 pri.create(name="fatal-bug", order="1") | |
| 130 pri.create(name="bug", order="2") | |
| 131 pri.create(name="usability", order="3") | |
| 132 pri.create(name="feature", order="4") | |
| 133 pri.create(name="support", order="5") | |
| 134 | |
| 135 stat = db.getclass('status') | |
| 136 stat.create(name="unread", order="1") | |
| 137 stat.create(name="deferred", order="2") | |
| 138 stat.create(name="chatting", order="3") | |
| 139 stat.create(name="need-eg", order="4") | |
| 140 stat.create(name="in-progress", order="5") | |
| 141 stat.create(name="testing", order="6") | |
| 142 stat.create(name="done-cbb", order="7") | |
| 143 stat.create(name="resolved", order="8") | |
| 144 | |
| 145 rate = db.getclass("rate") | |
| 146 rate.create(name='basic', order="1") | |
| 147 rate.create(name='premium', order="2") | |
| 148 rate.create(name='internal', order="3") | |
| 149 | |
| 150 source = db.getclass("source") | |
| 151 source.create(name='phone', order="1") | |
| 152 source.create(name='e-mail', order="2") | |
| 153 source.create(name='internal', order="3") | |
| 154 source.create(name='internal-qa', order="4") | |
| 155 | |
| 156 platform = db.getclass("platform") | |
| 157 platform.create(name='linux', order="1") | |
| 158 platform.create(name='windows', order="2") | |
| 159 platform.create(name='mac', order="3") | |
| 160 | |
| 161 product = db.getclass("product") | |
| 162 product.create(name='Bizar Shop', order="1") | |
| 163 product.create(name='Bizar Shop Developer', order="2") | |
| 164 product.create(name='Bizar Shop Manual', order="3") | |
| 165 product.create(name='Bizar Shop Developer Manual', order="4") | |
| 166 | |
| 167 user = db.getclass('user') | |
| 168 user.create(username="admin", password=adminpw, | |
| 169 address=instance_config.ADMIN_EMAIL) | |
| 170 | |
| 171 db.close() | |
| 172 | |
| 173 # | |
| 174 # $Log: not supported by cvs2svn $ | |
| 175 # Revision 1.1 2001/07/23 03:50:46 anthonybaxter | |
| 176 # moved templates to proper location | |
| 177 # | |
| 178 # Revision 1.2 2001/07/22 12:09:32 richard | |
| 179 # Final commit of Grande Splite | |
| 180 # | |
| 181 # | |
| 182 | |
| 183 |
