Skip to content

Commit 088a208

Browse files
author
Anthony Baxter
committed
split __init__.py into 2. dbinit and instance_config.
1 parent 8d1b6a8 commit 088a208

File tree

3 files changed

+234
-183
lines changed

3 files changed

+234
-183
lines changed
Lines changed: 4 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -1,187 +1,8 @@
1-
# $Id: __init__.py,v 1.1 2001-07-23 03:50:46 anthonybaxter Exp $
1+
# $Id: __init__.py,v 1.2 2001-07-23 04:33:21 anthonybaxter Exp $
22

3-
MAIL_DOMAIN=MAILHOST=HTTP_HOST=None
4-
HTTP_PORT=0
3+
from instance_config import *
4+
from dbinit import *
55

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-
#
6+
#
1817
# $Log: not supported by cvs2svn $
182-
# Revision 1.2 2001/07/22 12:09:32 richard
183-
# Final commit of Grande Splite
1848
#
185-
#
186-
187-
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
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+

0 commit comments

Comments
 (0)