Code

. all storage-specific code (ie. backend) is now implemented by the backends
[roundup.git] / roundup / templates / extended / dbinit.py
index 62c546e66935a94e462aec6c0c8eb78ab7a2623a..0ada216bde71f11f1f8e46f6ec901c0630149145 100644 (file)
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: dbinit.py,v 1.19 2002-01-14 02:20:15 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
-    '''
-    pass
-
 def open(name=None):
     ''' as from the roundupdb method openDB 
  
@@ -47,7 +31,15 @@ def open(name=None):
     # open the database
     db = Database(instance_config, name)
 
-    # Now initialise the schema. Must do this each time.
+    #
+    # Now initialise the schema. Must do this each time the database is
+    # opened.
+    #
+
+    # Class automatically gets these properties:
+    #   creation = Date()
+    #   activity = Date()
+    #   creator = Link('user')
     pri = Class(db, "priority", 
                     name=String(), order=String())
     pri.setkey("name")
@@ -63,9 +55,13 @@ 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(), 
@@ -96,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"),
@@ -112,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):
@@ -173,6 +179,39 @@ def init(adminpw):
 
 #
 # $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: