From: anthonybaxter Date: Mon, 23 Jul 2001 04:33:21 +0000 (+0000) Subject: split __init__.py into 2. dbinit and instance_config. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3374898faf2630176e2197f0c2b2bf55d3d415c1;p=roundup.git split __init__.py into 2. dbinit and instance_config. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@40 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/templates/extended/__init__.py b/roundup/templates/extended/__init__.py index 2d061fd..a594565 100644 --- a/roundup/templates/extended/__init__.py +++ b/roundup/templates/extended/__init__.py @@ -1,187 +1,8 @@ -# $Id: __init__.py,v 1.1 2001-07-23 03:50:46 anthonybaxter Exp $ +# $Id: __init__.py,v 1.2 2001-07-23 04:33:21 anthonybaxter Exp $ -MAIL_DOMAIN=MAILHOST=HTTP_HOST=None -HTTP_PORT=0 +from instance_config import * +from dbinit import * -try: - from localconfig import * -except ImportError: - localconfig = None - -import os - -# roundup home is this package's directory -ROUNDUP_HOME=os.path.split(__file__)[0] - -# The SMTP mail host that roundup will use to send mail -if not MAILHOST: - MAILHOST = 'localhost' - -# The domain name used for email addresses. -if not MAIL_DOMAIN: - MAIL_DOMAIN = 'bizarsoftware.com.au' - -# the next two are only used for the standalone HTTP server. -if not HTTP_HOST: - HTTP_HOST = '' -if not HTTP_PORT: - HTTP_PORT = 9080 - -# This is the directory that the database is going to be stored in -DATABASE = os.path.join(ROUNDUP_HOME, 'db') - -# This is the directory that the HTML templates reside in -TEMPLATES = os.path.join(ROUNDUP_HOME, 'templates') - -# The email address that mail to roundup should go to -ISSUE_TRACKER_EMAIL = 'issue_tracker@%s'%MAIL_DOMAIN - -# The email address that roundup will complain to if it runs into trouble -ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN - -# Somewhere for roundup to log stuff internally sent to stdout or stderr -LOG = os.path.join(ROUNDUP_HOME, 'roundup.log') - - -from roundup import hyperdb, hyper_bsddb, roundupdb, cgi_client, mailgw - -class Database(roundupdb.Database, hyper_bsddb.Database): - ''' Creates a hybrid database from: - . the base Database class given in hyperdb (basic functionlity) - . the BSDDB implementation in hyperdb_bsddb - . the roundup extensions from roundupdb - ''' - pass - -Class = roundupdb.Class -class IssueClass(roundupdb.IssueClass): - ''' issues need the email information - ''' - ISSUE_TRACKER_EMAIL = ISSUE_TRACKER_EMAIL - ADMIN_EMAIL = ADMIN_EMAIL - MAILHOST = MAILHOST - -FileClass = roundupdb.FileClass - -class Client(cgi_client.Client): - ''' derives basic mail gateway implementation from the standard module, - with any specific extensions - ''' - TEMPLATES = TEMPLATES - pass - -class MailGW(mailgw.MailGW): - ''' derives basic mail gateway implementation from the standard module, - with any specific extensions - ''' - ISSUE_TRACKER_EMAIL = ISSUE_TRACKER_EMAIL - ADMIN_EMAIL = ADMIN_EMAIL - MAILHOST = MAILHOST - -def open(name=None): - ''' as from the roundupdb method openDB - - storagelocator must be the directory the __init__.py file is in - - os.path.split(__file__)[0] gives us that I think - ''' - db = Database(DATABASE, name) - pri = Class(db, "priority", name=hyperdb.String(), order=hyperdb.String()) - pri.setkey("name") - stat = Class(db, "status", name=hyperdb.String(), order=hyperdb.String()) - stat.setkey("name") - Class(db, "keyword", name=hyperdb.String()) - user = Class(db, "user", username=hyperdb.String(), - password=hyperdb.String(), address=hyperdb.String(), - realname=hyperdb.String(), phone=hyperdb.String(), - organisation=hyperdb.String()) - user.setkey("username") - msg = FileClass(db, "msg", author=hyperdb.Link("user"), - recipients=hyperdb.Multilink("user"), date=hyperdb.Date(), - summary=hyperdb.String(), files=hyperdb.Multilink("file")) - file = FileClass(db, "file", name=hyperdb.String(), type=hyperdb.String()) - - # bugs and support calls etc - rate = Class(db, "rate", name=hyperdb.String(), order=hyperdb.String()) - rate.setkey("name") - source = Class(db, "source", name=hyperdb.String(), order=hyperdb.String()) - source.setkey("name") - platform = Class(db, "platform", name=hyperdb.String(), order=hyperdb.String()) - platform.setkey("name") - product = Class(db, "product", name=hyperdb.String(), order=hyperdb.String()) - product.setkey("name") - Class(db, "timelog", date=hyperdb.Date(), time=hyperdb.String(), - performedby=hyperdb.Link("user"), description=hyperdb.String()) - issue = IssueClass(db, "issue", assignedto=hyperdb.Link("user"), - priority=hyperdb.Link("priority"), status=hyperdb.Link("status"), - rate=hyperdb.Link("rate"), source=hyperdb.Link("source"), - product=hyperdb.Link("product"), platform=hyperdb.Multilink("platform"), - version=hyperdb.String(), - timelog=hyperdb.Multilink("timelog"), customername=hyperdb.String()) - issue.setkey('title') - import detectors - detectors.init(db) - return db - -def init(adminpw): - ''' as from the roundupdb method initDB - - storagelocator must be the directory the __init__.py file is in - - os.path.split(__file__)[0] gives us that I think - ''' - dbdir = os.path.join(DATABASE, 'files') - if not os.path.isdir(dbdir): - os.makedirs(dbdir) - db = open("admin") - db.clear() - pri = db.getclass('priority') - pri.create(name="fatal-bug", order="1") - pri.create(name="bug", order="2") - pri.create(name="usability", order="3") - pri.create(name="feature", order="4") - pri.create(name="support", order="5") - - stat = db.getclass('status') - stat.create(name="unread", order="1") - stat.create(name="deferred", order="2") - stat.create(name="chatting", order="3") - stat.create(name="need-eg", order="4") - stat.create(name="in-progress", order="5") - stat.create(name="testing", order="6") - stat.create(name="done-cbb", order="7") - stat.create(name="resolved", order="8") - - rate = db.getclass("rate") - rate.create(name='basic', order="1") - rate.create(name='premium', order="2") - rate.create(name='internal', order="3") - - source = db.getclass("source") - source.create(name='phone', order="1") - source.create(name='e-mail', order="2") - source.create(name='internal', order="3") - source.create(name='internal-qa', order="4") - - platform = db.getclass("platform") - platform.create(name='linux', order="1") - platform.create(name='windows', order="2") - platform.create(name='mac', order="3") - - product = db.getclass("product") - product.create(name='Bizar Shop', order="1") - product.create(name='Bizar Shop Developer', order="2") - product.create(name='Bizar Shop Manual', order="3") - product.create(name='Bizar Shop Developer Manual', order="4") - - user = db.getclass('user') - user.create(username="admin", password=adminpw, address=ADMIN_EMAIL) - - db.close() - -# +# # $Log: not supported by cvs2svn $ -# Revision 1.2 2001/07/22 12:09:32 richard -# Final commit of Grande Splite # -# - - diff --git a/roundup/templates/extended/dbinit.py b/roundup/templates/extended/dbinit.py new file mode 100644 index 0000000..f203836 --- /dev/null +++ b/roundup/templates/extended/dbinit.py @@ -0,0 +1,183 @@ +# $Id: dbinit.py,v 1.1 2001-07-23 04:33:21 anthonybaxter Exp $ + +import instance_config +from roundup import hyperdb, hyper_bsddb, roundupdb, cgi_client, mailgw + +from roundup.roundupdb import Class, FileClass +import os + + +class Database(roundupdb.Database, hyper_bsddb.Database): + ''' Creates a hybrid database from: + . the base Database class given in hyperdb (basic functionlity) + . the BSDDB implementation in hyperdb_bsddb + . the roundup extensions from roundupdb + ''' + pass + +class IssueClass(roundupdb.IssueClass): + ''' issues need the email information + ''' + ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL + ADMIN_EMAIL = instance_config.ADMIN_EMAIL + MAILHOST = instance_config.MAILHOST + + +class Client(cgi_client.Client): + ''' derives basic mail gateway implementation from the standard module, + with any specific extensions + ''' + TEMPLATES = instance_config.TEMPLATES + pass + +class MailGW(mailgw.MailGW): + ''' derives basic mail gateway implementation from the standard module, + with any specific extensions + ''' + ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL + ADMIN_EMAIL = instance_config.ADMIN_EMAIL + MAILHOST = instance_config.MAILHOST + +def open(name=None): + ''' as from the roundupdb method openDB + + storagelocator must be the directory the __init__.py file is in + - os.path.split(__file__)[0] gives us that I think + ''' + from roundup.hyperdb import String, Date, Link, Multilink + + # open the database + db = Database(instance_config.DATABASE, name) + + # Now initialise the schema. Must do this each time. + pri = Class(db, "priority", + name=String(), order=String()) + pri.setkey("name") + + stat = Class(db, "status", + name=String(), order=String()) + stat.setkey("name") + + keywords = Class(db, "keyword", + name=String()) + + user = Class(db, "user", + username=String(), password=String(), + address=String(), realname=String(), + phone=String(), organisation=String()) + user.setkey("username") + + msg = FileClass(db, "msg", + author=Link("user"), recipients=Multilink("user"), + date=Date(), summary=String(), + files=Multilink("file")) + + file = FileClass(db, "file", + name=String(), type=String()) + + # bugs and support calls etc + rate = Class(db, "rate", + name=String(), order=String()) + rate.setkey("name") + + source = Class(db, "source", + name=String(), order=String()) + source.setkey("name") + + platform = Class(db, "platform", + name=String(), order=String()) + platform.setkey("name") + + product = Class(db, "product", + name=String(), order=String()) + product.setkey("name") + + timelog = Class(db, "timelog", + date=Date(), time=String(), + performedby=Link("user"), description=String()) + + issue = IssueClass(db, "issue", + assignedto=Link("user"), priority=Link("priority"), + status=Link("status"), rate=Link("rate"), + source=Link("source"), product=Link("product"), + platform=Multilink("platform"), version=String(), + timelog=Multilink("timelog"), customername=String()) + issue.setkey('title') + + import detectors + detectors.init(db) + + return db + +def init(adminpw): + ''' as from the roundupdb method initDB + + storagelocator must be the directory the __init__.py file is in + - os.path.split(__file__)[0] gives us that I think + + Open the new database, and set up a bunch of attributes. + + ''' + dbdir = os.path.join(instance_config.DATABASE, 'files') + if not os.path.isdir(dbdir): + os.makedirs(dbdir) + + db = open("admin") + db.clear() + + pri = db.getclass('priority') + pri.create(name="fatal-bug", order="1") + pri.create(name="bug", order="2") + pri.create(name="usability", order="3") + pri.create(name="feature", order="4") + pri.create(name="support", order="5") + + stat = db.getclass('status') + stat.create(name="unread", order="1") + stat.create(name="deferred", order="2") + stat.create(name="chatting", order="3") + stat.create(name="need-eg", order="4") + stat.create(name="in-progress", order="5") + stat.create(name="testing", order="6") + stat.create(name="done-cbb", order="7") + stat.create(name="resolved", order="8") + + rate = db.getclass("rate") + rate.create(name='basic', order="1") + rate.create(name='premium', order="2") + rate.create(name='internal', order="3") + + source = db.getclass("source") + source.create(name='phone', order="1") + source.create(name='e-mail', order="2") + source.create(name='internal', order="3") + source.create(name='internal-qa', order="4") + + platform = db.getclass("platform") + platform.create(name='linux', order="1") + platform.create(name='windows', order="2") + platform.create(name='mac', order="3") + + product = db.getclass("product") + product.create(name='Bizar Shop', order="1") + product.create(name='Bizar Shop Developer', order="2") + product.create(name='Bizar Shop Manual', order="3") + product.create(name='Bizar Shop Developer Manual', order="4") + + user = db.getclass('user') + user.create(username="admin", password=adminpw, + address=instance_config.ADMIN_EMAIL) + + db.close() + +# +# $Log: not supported by cvs2svn $ +# Revision 1.1 2001/07/23 03:50:46 anthonybaxter +# moved templates to proper location +# +# Revision 1.2 2001/07/22 12:09:32 richard +# Final commit of Grande Splite +# +# + + diff --git a/roundup/templates/extended/instance_config.py b/roundup/templates/extended/instance_config.py new file mode 100644 index 0000000..653983d --- /dev/null +++ b/roundup/templates/extended/instance_config.py @@ -0,0 +1,47 @@ +# $Id: instance_config.py,v 1.1 2001-07-23 04:33:21 anthonybaxter Exp $ + +MAIL_DOMAIN=MAILHOST=HTTP_HOST=None +HTTP_PORT=0 + +try: + from localconfig import * +except ImportError: + localconfig = None + +import os + +# roundup home is this package's directory +INSTANCE_HOME=os.path.split(__file__)[0] + +# The SMTP mail host that roundup will use to send mail +if not MAILHOST: + MAILHOST = 'localhost' + +# The domain name used for email addresses. +if not MAIL_DOMAIN: + MAIL_DOMAIN = 'bizarsoftware.com.au' + +# the next two are only used for the standalone HTTP server. +if not HTTP_HOST: + HTTP_HOST = '' +if not HTTP_PORT: + HTTP_PORT = 9080 + +# This is the directory that the database is going to be stored in +DATABASE = os.path.join(INSTANCE_HOME, 'db') + +# This is the directory that the HTML templates reside in +TEMPLATES = os.path.join(INSTANCE_HOME, 'html') + +# The email address that mail to roundup should go to +ISSUE_TRACKER_EMAIL = 'issue_tracker@%s'%MAIL_DOMAIN + +# The email address that roundup will complain to if it runs into trouble +ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN + +# Somewhere for roundup to log stuff internally sent to stdout or stderr +LOG = os.path.join(INSTANCE_HOME, 'roundup.log') + +# +# $Log: not supported by cvs2svn $ +#