index a48553c9050a7bb66f6a8f5442e475cf0b8f3050..0cb944d9af3fc408ffdfe3da5f59a7b072af53e6 100644 (file)
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: dbinit.py,v 1.9 2001-10-30 00:54:45 richard Exp $
+# $Id: dbinit.py,v 1.27 2002-09-11 01:18:24 richard Exp $
import os
-import instance_config
-from roundup import roundupdb
-import select_db
+import config
+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
- '''
- 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
-
-
def open(name=None):
''' as from the roundupdb method openDB
-
'''
from roundup.hyperdb import String, Password, Date, Link, Multilink
# open the database
- db = Database(instance_config.DATABASE, name)
+ db = Database(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")
keyword = Class(db, "keyword",
name=String())
keyword.setkey("name")
-
+
+ query = Class(db, "query",
+ klass=String(), name=String(),
+ url=String())
+ query.setkey("name")
+
+ # Note: roles is a comma-separated string of Role names
user = Class(db, "user",
username=String(), password=Password(),
address=String(), realname=String(),
- phone=String(), organisation=String())
+ phone=String(), organisation=String(),
+ alternate_addresses=String(),
+ queries=Multilink('query'), roles=String())
user.setkey("username")
+ # FileClass automatically gets these properties:
+ # content = String() [saved to disk in <tracker home>/db/files/]
+ # (it also gets the Class properties creation, activity and creator)
msg = FileClass(db, "msg",
- author=Link("user"), recipients=Multilink("user"),
+ author=Link("user", do_journal='no'),
+ recipients=Multilink("user", do_journal='no'),
date=Date(), summary=String(),
- files=Multilink("file"))
+ files=Multilink("file"),
+ messageid=String(), inreplyto=String())
file = FileClass(db, "file",
name=String(), type=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)
issue = IssueClass(db, "issue",
assignedto=Link("user"), topic=Multilink("keyword"),
priority=Link("priority"), status=Link("status"))
- issue.setkey('title')
+
+ #
+ # SECURITY SETTINGS
+ #
+ # new permissions for this schema
+ for cl in 'issue', 'file', 'msg', 'user':
+ db.security.addPermission(name="Edit", klass=cl,
+ description="User is allowed to edit "+cl)
+ db.security.addPermission(name="View", klass=cl,
+ description="User is allowed to access "+cl)
+
+ # Assign the access and edit permissions for issue, file and message
+ # to regular users now
+ for cl in 'issue', 'file', 'msg':
+ p = db.security.getPermission('View', cl)
+ db.security.addPermissionToRole('User', p)
+ p = db.security.getPermission('Edit', cl)
+ db.security.addPermissionToRole('User', p)
+ # and give the regular users access to the web and email interface
+ p = db.security.getPermission('Web Access')
+ db.security.addPermissionToRole('User', p)
+ p = db.security.getPermission('Email Access')
+ db.security.addPermissionToRole('User', p)
+
+ # May users view other user information? Comment these lines out
+ # if you don't want them to
+ p = db.security.getPermission('View', 'user')
+ db.security.addPermissionToRole('User', p)
+
+ # Assign the appropriate permissions to the anonymous user's Anonymous
+ # Role. Choices here are:
+ # - Allow anonymous users to register through the web
+ p = db.security.getPermission('Web Registration')
+ db.security.addPermissionToRole('Anonymous', p)
+ # - Allow anonymous (new) users to register through the email gateway
+ p = db.security.getPermission('Email Registration')
+ db.security.addPermissionToRole('Anonymous', p)
+ # - Allow anonymous users access to the "issue" class of data
+ # Note: this also grants access to related information like files,
+ # messages, statuses etc that are linked to issues
+ p = db.security.getPermission('View', 'issue')
+ db.security.addPermissionToRole('Anonymous', p)
+ # - Allow anonymous users access to edit the "issue" class of data
+ # Note: this also grants access to create related information like
+ # files and messages etc that are linked to issues
+ #p = db.security.getPermission('Edit', 'issue')
+ #db.security.addPermissionToRole('Anonymous', p)
+
+ # oh, g'wan, let anonymous access the web interface too
+ p = db.security.getPermission('Web Access')
+ db.security.addPermissionToRole('Anonymous', p)
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')
+ dbdir = os.path.join(config.DATABASE, 'files')
if not os.path.isdir(dbdir):
os.makedirs(dbdir)
db = open("admin")
db.clear()
+ #
+ # INITIAL PRIORITY AND STATUS VALUES
+ #
pri = db.getclass('priority')
pri.create(name="critical", order="1")
pri.create(name="urgent", order="2")
stat.create(name="done-cbb", order="7")
stat.create(name="resolved", order="8")
+ # create the two default users
user = db.getclass('user')
- user.create(username="admin", password=adminpw,
- address=instance_config.ADMIN_EMAIL)
+ user.create(username="admin", password=adminpw,
+ address=config.ADMIN_EMAIL, roles='Admin')
+ user.create(username="anonymous", roles='Anonymous')
- db.close()
+ db.commit()
-#
-# $Log: not supported by cvs2svn $
-# Revision 1.8 2001/10/09 07:25:59 richard
-# Added the Password property type. See "pydoc roundup.password" for
-# implementation details. Have updated some of the documentation too.
-#
-# Revision 1.7 2001/08/07 00:24:43 richard
-# stupid typo
-#
-# Revision 1.6 2001/08/07 00:15:51 richard
-# Added the copyright/license notice to (nearly) all files at request of
-# Bizar Software.
-#
-# Revision 1.5 2001/08/02 06:38:17 richard
-# Roundupdb now appends "mailing list" information to its messages which
-# include the e-mail address and web interface address. Templates may
-# override this in their db classes to include specific information (support
-# instructions, etc).
-#
-# Revision 1.4 2001/07/29 07:01:39 richard
-# Added vim command to all source so that we don't get no steenkin' tabs :)
-#
-# Revision 1.3 2001/07/24 10:46:22 anthonybaxter
-# Added templatebuilder module. two functions - one to pack up the html base,
-# one to unpack it. Packed up the two standard templates into htmlbases.
-# Modified __init__ to install them.
-#
-# __init__.py magic was needed for the rather high levels of wierd import magic.
-# Reducing level of import magic == (good, future)
-#
-# Revision 1.2 2001/07/24 01:06:43 richard
-# Oops - accidentally duped the keywords class
-#
-# Revision 1.1 2001/07/23 23:28:43 richard
-# Adding the classic template
-#
-# Revision 1.4 2001/07/23 08:45:28 richard
-# ok, so now "./roundup-admin init" will ask questions in an attempt to get a
-# workable instance_home set up :)
-# _and_ anydbm has had its first test :)
-#
-# Revision 1.3 2001/07/23 07:14:41 richard
-# Moved the database backends off into backends.
-#
-# Revision 1.2 2001/07/23 06:25:50 richard
-# relfected the move to roundup/backends
-#
-# Revision 1.1 2001/07/23 04:33:21 anthonybaxter
-# split __init__.py into 2. dbinit and instance_config.
-#
-# 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
-#
-#
# vim: set filetype=python ts=4 sw=4 et si