Code

. all storage-specific code (ie. backend) is now implemented by the backends
[roundup.git] / roundup / templates / extended / dbinit.py
index 2a92ea7ff15f89b611d332b82aeb87588148251c..0ada216bde71f11f1f8e46f6ec901c0630149145 100644 (file)
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: dbinit.py,v 1.15 2001-11-26 22:55:56 richard Exp $
+# $Id: dbinit.py,v 1.23 2002-07-14 02:05:54 richard Exp $
 
 import os
 
 import instance_config
-from roundup import roundupdb
-import select_db
+from select_db import Database, Class, FileClass, IssueClass
 
-from roundup.roundupdb import Class, FileClass
-
-class Database(roundupdb.Database, select_db.Database):
-    ''' Creates a hybrid database from: 
-         . the selected database back-end from select_db
-         . the roundup extensions from roundupdb 
-    ''' 
-    pass 
-
-class IssueClass(roundupdb.IssueClass):
-    ''' issues need the email information
-    '''
-    INSTANCE_NAME = instance_config.INSTANCE_NAME
-    ISSUE_TRACKER_WEB = instance_config.ISSUE_TRACKER_WEB
-    ISSUE_TRACKER_EMAIL = instance_config.ISSUE_TRACKER_EMAIL
-    ADMIN_EMAIL = instance_config.ADMIN_EMAIL
-    MAILHOST = instance_config.MAILHOST
-    MESSAGES_TO_AUTHOR = instance_config.MESSAGES_TO_AUTHOR
-    EMAIL_SIGNATURE_POSITION = instance_config.EMAIL_SIGNATURE_POSITION
-
 def open(name=None):
     ''' as from the roundupdb method openDB 
  
@@ -51,9 +29,17 @@ def open(name=None):
     from roundup.hyperdb import String, Password, Date, Link, Multilink
 
     # open the database
-    db = Database(instance_config.DATABASE, name)
+    db = Database(instance_config, name)
+
+    #
+    # Now initialise the schema. Must do this each time the database is
+    # opened.
+    #
 
-    # Now initialise the schema. Must do this each time.
+    # Class automatically gets these properties:
+    #   creation = Date()
+    #   activity = Date()
+    #   creator = Link('user')
     pri = Class(db, "priority", 
                     name=String(), order=String())
     pri.setkey("name")
@@ -69,13 +55,18 @@ def open(name=None):
     user = Class(db, "user", 
                     username=String(),   password=Password(),
                     address=String(),    realname=String(), 
-                    phone=String(),      organisation=String())
+                    phone=String(),      organisation=String(),
+                    alternate_addresses=String())
     user.setkey("username")
 
+    # FileClass automatically gets these properties:
+    #   content = String()    [saved to disk in <instance home>/db/files/]
+    #   (it also gets the Class properties creation, activity and creator)
     msg = FileClass(db, "msg", 
                     author=Link("user"), recipients=Multilink("user"), 
                     date=Date(),         summary=String(), 
-                    files=Multilink("file"))
+                    files=Multilink("file"),
+                    messageid=String(),  inreplyto=String())
 
     file = FileClass(db, "file", 
                     name=String(),       type=String())
@@ -101,6 +92,13 @@ def open(name=None):
                     date=Date(),         time=String(),
                     performedby=Link("user"), description=String())
 
+    # IssueClass automatically gets these properties:
+    #   title = String()
+    #   messages = Multilink("msg")
+    #   files = Multilink("file")
+    #   nosy = Multilink("user")
+    #   superseder = Multilink("issue")
+    #   (it also gets the Class properties creation, activity and creator)
     support = IssueClass(db, "support", 
                     assignedto=Link("user"), status=Link("status"),
                     rate=Link("rate"), source=Link("source"),
@@ -117,13 +115,16 @@ def open(name=None):
     import detectors
     detectors.init(db)
 
+    # schema is set up - run any post-initialisation
+    db.post_init()
     return db
  
 def init(adminpw): 
     ''' as from the roundupdb method initDB 
  
-    Open the new database, and set up a bunch of attributes.
-
+    Open the new database, and add new nodes - used for initialisation. You
+    can edit this before running the "roundup-admin initialise" command to
+    change the initial database entries.
     ''' 
     dbdir = os.path.join(instance_config.DATABASE, 'files')
     if not os.path.isdir(dbdir):
@@ -174,10 +175,93 @@ def init(adminpw):
     user.create(username="admin", password=adminpw, 
                                   address=instance_config.ADMIN_EMAIL)
 
-    db.close()
+    db.commit()
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.22  2002/07/09 03:02:53  richard
+# More indexer work:
+# - all String properties may now be indexed too. Currently there's a bit of
+#   "issue" specific code in the actual searching which needs to be
+#   addressed. In a nutshell:
+#   + pass 'indexme="yes"' as a String() property initialisation arg, eg:
+#         file = FileClass(db, "file", name=String(), type=String(),
+#             comment=String(indexme="yes"))
+#   + the comment will then be indexed and be searchable, with the results
+#     related back to the issue that the file is linked to
+# - as a result of this work, the FileClass has a default MIME type that may
+#   be overridden in a subclass, or by the use of a "type" property as is
+#   done in the default templates.
+# - the regeneration of the indexes (if necessary) is done once the schema is
+#   set up in the dbinit.
+#
+# Revision 1.21  2002/05/24 04:03:23  richard
+# Added commentage to the dbinit files to help people with their
+# customisation.
+#
+# Revision 1.20  2002/02/15 07:08:44  richard
+#  . Alternate email addresses are now available for users. See the MIGRATION
+#    file for info on how to activate the feature.
+#
+# Revision 1.19  2002/01/14 02:20:15  richard
+#  . changed all config accesses so they access either the instance or the
+#    config attriubute on the db. This means that all config is obtained from
+#    instance_config instead of the mish-mash of classes. This will make
+#    switching to a ConfigParser setup easier too, I hope.
+#
+# At a minimum, this makes migration a _little_ easier (a lot easier in the
+# 0.5.0 switch, I hope!)
+#
+# Revision 1.18  2002/01/02 02:31:38  richard
+# Sorry for the huge checkin message - I was only intending to implement #496356
+# but I found a number of places where things had been broken by transactions:
+#  . modified ROUNDUPDBSENDMAILDEBUG to be SENDMAILDEBUG and hold a filename
+#    for _all_ roundup-generated smtp messages to be sent to.
+#  . the transaction cache had broken the roundupdb.Class set() reactors
+#  . newly-created author users in the mailgw weren't being committed to the db
+#
+# Stuff that made it into CHANGES.txt (ie. the stuff I was actually working
+# on when I found that stuff :):
+#  . #496356 ] Use threading in messages
+#  . detectors were being registered multiple times
+#  . added tests for mailgw
+#  . much better attaching of erroneous messages in the mail gateway
+#
+# Revision 1.17  2001/12/02 05:06:16  richard
+# . We now use weakrefs in the Classes to keep the database reference, so
+#   the close() method on the database is no longer needed.
+#   I bumped the minimum python requirement up to 2.1 accordingly.
+# . #487480 ] roundup-server
+# . #487476 ] INSTALL.txt
+#
+# I also cleaned up the change message / post-edit stuff in the cgi client.
+# There's now a clearly marked "TODO: append the change note" where I believe
+# the change note should be added there. The "changes" list will obviously
+# have to be modified to be a dict of the changes, or somesuch.
+#
+# More testing needed.
+#
+# Revision 1.16  2001/12/01 07:17:50  richard
+# . We now have basic transaction support! Information is only written to
+#   the database when the commit() method is called. Only the anydbm
+#   backend is modified in this way - neither of the bsddb backends have been.
+#   The mail, admin and cgi interfaces all use commit (except the admin tool
+#   doesn't have a commit command, so interactive users can't commit...)
+# . Fixed login/registration forwarding the user to the right page (or not,
+#   on a failure)
+#
+# Revision 1.15  2001/11/26 22:55:56  richard
+# Feature:
+#  . Added INSTANCE_NAME to configuration - used in web and email to identify
+#    the instance.
+#  . Added EMAIL_SIGNATURE_POSITION to indicate where to place the roundup
+#    signature info in e-mails.
+#  . Some more flexibility in the mail gateway and more error handling.
+#  . Login now takes you to the page you back to the were denied access to.
+#
+# Fixed:
+#  . Lots of bugs, thanks Roché and others on the devel mailing list!
+#
 # Revision 1.14  2001/11/21 02:34:18  richard
 # Added a target version field to the extended issue schema
 #