|
| 1 | +# $Id: __init__.py,v 1.1 2001-07-23 03:50:46 anthonybaxter Exp $ |
| 2 | + |
| 3 | +MAIL_DOMAIN=MAILHOST=HTTP_HOST=None |
| 4 | +HTTP_PORT=0 |
| 5 | + |
| 6 | +try: |
| 7 | + from localconfig import * |
| 8 | +except ImportError: |
| 9 | + localconfig = None |
| 10 | + |
| 11 | +import os |
| 12 | + |
| 13 | +# roundup home is this package's directory |
| 14 | +ROUNDUP_HOME=os.path.split(__file__)[0] |
| 15 | + |
| 16 | +# The SMTP mail host that roundup will use to send mail |
| 17 | +if not MAILHOST: |
| 18 | + MAILHOST = 'localhost' |
| 19 | + |
| 20 | +# The domain name used for email addresses. |
| 21 | +if not MAIL_DOMAIN: |
| 22 | + MAIL_DOMAIN = 'bizarsoftware.com.au' |
| 23 | + |
| 24 | +# the next two are only used for the standalone HTTP server. |
| 25 | +if not HTTP_HOST: |
| 26 | + HTTP_HOST = '' |
| 27 | +if not HTTP_PORT: |
| 28 | + HTTP_PORT = 9080 |
| 29 | + |
| 30 | +# This is the directory that the database is going to be stored in |
| 31 | +DATABASE = os.path.join(ROUNDUP_HOME, 'db') |
| 32 | + |
| 33 | +# This is the directory that the HTML templates reside in |
| 34 | +TEMPLATES = os.path.join(ROUNDUP_HOME, 'templates') |
| 35 | + |
| 36 | +# The email address that mail to roundup should go to |
| 37 | +ISSUE_TRACKER_EMAIL = 'issue_tracker@%s'%MAIL_DOMAIN |
| 38 | + |
| 39 | +# The email address that roundup will complain to if it runs into trouble |
| 40 | +ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN |
| 41 | + |
| 42 | +# Somewhere for roundup to log stuff internally sent to stdout or stderr |
| 43 | +LOG = os.path.join(ROUNDUP_HOME, 'roundup.log') |
| 44 | + |
| 45 | + |
| 46 | +from roundup import hyperdb, hyper_bsddb, roundupdb, cgi_client, mailgw |
| 47 | + |
| 48 | +class Database(roundupdb.Database, hyper_bsddb.Database): |
| 49 | + ''' Creates a hybrid database from: |
| 50 | + . the base Database class given in hyperdb (basic functionlity) |
| 51 | + . the BSDDB implementation in hyperdb_bsddb |
| 52 | + . the roundup extensions from roundupdb |
| 53 | + ''' |
| 54 | + pass |
| 55 | + |
| 56 | +Class = roundupdb.Class |
| 57 | +class IssueClass(roundupdb.IssueClass): |
| 58 | + ''' issues need the email information |
| 59 | + ''' |
| 60 | + ISSUE_TRACKER_EMAIL = ISSUE_TRACKER_EMAIL |
| 61 | + ADMIN_EMAIL = ADMIN_EMAIL |
| 62 | + MAILHOST = MAILHOST |
| 63 | + |
| 64 | +FileClass = roundupdb.FileClass |
| 65 | + |
| 66 | +class Client(cgi_client.Client): |
| 67 | + ''' derives basic mail gateway implementation from the standard module, |
| 68 | + with any specific extensions |
| 69 | + ''' |
| 70 | + TEMPLATES = TEMPLATES |
| 71 | + pass |
| 72 | + |
| 73 | +class MailGW(mailgw.MailGW): |
| 74 | + ''' derives basic mail gateway implementation from the standard module, |
| 75 | + with any specific extensions |
| 76 | + ''' |
| 77 | + ISSUE_TRACKER_EMAIL = ISSUE_TRACKER_EMAIL |
| 78 | + ADMIN_EMAIL = ADMIN_EMAIL |
| 79 | + MAILHOST = MAILHOST |
| 80 | + |
| 81 | +def open(name=None): |
| 82 | + ''' as from the roundupdb method openDB |
| 83 | + |
| 84 | + storagelocator must be the directory the __init__.py file is in |
| 85 | + - os.path.split(__file__)[0] gives us that I think |
| 86 | + ''' |
| 87 | + db = Database(DATABASE, name) |
| 88 | + pri = Class(db, "priority", name=hyperdb.String(), order=hyperdb.String()) |
| 89 | + pri.setkey("name") |
| 90 | + stat = Class(db, "status", name=hyperdb.String(), order=hyperdb.String()) |
| 91 | + stat.setkey("name") |
| 92 | + Class(db, "keyword", name=hyperdb.String()) |
| 93 | + user = Class(db, "user", username=hyperdb.String(), |
| 94 | + password=hyperdb.String(), address=hyperdb.String(), |
| 95 | + realname=hyperdb.String(), phone=hyperdb.String(), |
| 96 | + organisation=hyperdb.String()) |
| 97 | + user.setkey("username") |
| 98 | + msg = FileClass(db, "msg", author=hyperdb.Link("user"), |
| 99 | + recipients=hyperdb.Multilink("user"), date=hyperdb.Date(), |
| 100 | + summary=hyperdb.String(), files=hyperdb.Multilink("file")) |
| 101 | + file = FileClass(db, "file", name=hyperdb.String(), type=hyperdb.String()) |
| 102 | + |
| 103 | + # bugs and support calls etc |
| 104 | + rate = Class(db, "rate", name=hyperdb.String(), order=hyperdb.String()) |
| 105 | + rate.setkey("name") |
| 106 | + source = Class(db, "source", name=hyperdb.String(), order=hyperdb.String()) |
| 107 | + source.setkey("name") |
| 108 | + platform = Class(db, "platform", name=hyperdb.String(), order=hyperdb.String()) |
| 109 | + platform.setkey("name") |
| 110 | + product = Class(db, "product", name=hyperdb.String(), order=hyperdb.String()) |
| 111 | + product.setkey("name") |
| 112 | + Class(db, "timelog", date=hyperdb.Date(), time=hyperdb.String(), |
| 113 | + performedby=hyperdb.Link("user"), description=hyperdb.String()) |
| 114 | + issue = IssueClass(db, "issue", assignedto=hyperdb.Link("user"), |
| 115 | + priority=hyperdb.Link("priority"), status=hyperdb.Link("status"), |
| 116 | + rate=hyperdb.Link("rate"), source=hyperdb.Link("source"), |
| 117 | + product=hyperdb.Link("product"), platform=hyperdb.Multilink("platform"), |
| 118 | + version=hyperdb.String(), |
| 119 | + timelog=hyperdb.Multilink("timelog"), customername=hyperdb.String()) |
| 120 | + issue.setkey('title') |
| 121 | + import detectors |
| 122 | + detectors.init(db) |
| 123 | + return db |
| 124 | + |
| 125 | +def init(adminpw): |
| 126 | + ''' as from the roundupdb method initDB |
| 127 | + |
| 128 | + storagelocator must be the directory the __init__.py file is in |
| 129 | + - os.path.split(__file__)[0] gives us that I think |
| 130 | + ''' |
| 131 | + dbdir = os.path.join(DATABASE, 'files') |
| 132 | + if not os.path.isdir(dbdir): |
| 133 | + os.makedirs(dbdir) |
| 134 | + db = open("admin") |
| 135 | + db.clear() |
| 136 | + pri = db.getclass('priority') |
| 137 | + pri.create(name="fatal-bug", order="1") |
| 138 | + pri.create(name="bug", order="2") |
| 139 | + pri.create(name="usability", order="3") |
| 140 | + pri.create(name="feature", order="4") |
| 141 | + pri.create(name="support", order="5") |
| 142 | + |
| 143 | + stat = db.getclass('status') |
| 144 | + stat.create(name="unread", order="1") |
| 145 | + stat.create(name="deferred", order="2") |
| 146 | + stat.create(name="chatting", order="3") |
| 147 | + stat.create(name="need-eg", order="4") |
| 148 | + stat.create(name="in-progress", order="5") |
| 149 | + stat.create(name="testing", order="6") |
| 150 | + stat.create(name="done-cbb", order="7") |
| 151 | + stat.create(name="resolved", order="8") |
| 152 | + |
| 153 | + rate = db.getclass("rate") |
| 154 | + rate.create(name='basic', order="1") |
| 155 | + rate.create(name='premium', order="2") |
| 156 | + rate.create(name='internal', order="3") |
| 157 | + |
| 158 | + source = db.getclass("source") |
| 159 | + source.create(name='phone', order="1") |
| 160 | + source.create(name='e-mail', order="2") |
| 161 | + source.create(name='internal', order="3") |
| 162 | + source.create(name='internal-qa', order="4") |
| 163 | + |
| 164 | + platform = db.getclass("platform") |
| 165 | + platform.create(name='linux', order="1") |
| 166 | + platform.create(name='windows', order="2") |
| 167 | + platform.create(name='mac', order="3") |
| 168 | + |
| 169 | + product = db.getclass("product") |
| 170 | + product.create(name='Bizar Shop', order="1") |
| 171 | + product.create(name='Bizar Shop Developer', order="2") |
| 172 | + product.create(name='Bizar Shop Manual', order="3") |
| 173 | + product.create(name='Bizar Shop Developer Manual', order="4") |
| 174 | + |
| 175 | + user = db.getclass('user') |
| 176 | + user.create(username="admin", password=adminpw, address=ADMIN_EMAIL) |
| 177 | + |
| 178 | + db.close() |
| 179 | + |
| 180 | +# |
| 181 | +# $Log: not supported by cvs2svn $ |
| 182 | +# Revision 1.2 2001/07/22 12:09:32 richard |
| 183 | +# Final commit of Grande Splite |
| 184 | +# |
| 185 | +# |
| 186 | + |
| 187 | + |
0 commit comments