Author: barry.warsaw
Date: Sat Mar 19 17:02:47 2005
New Revision: 34

Added:
   trunk/mailman/src/mailman/database/
   trunk/mailman/src/mailman/database/__init__.py
   trunk/mailman/src/mailman/database/schema.py
Modified:
   trunk/mailman/src/mailman/__init__.py
   trunk/mailman/src/mailman/config/__init__.py
Log:
First (very preliminary) cut at SQLObject based schema.  This implements
MailingLists, and the roster objects.

Also remove the Bag class, which isn't used.



Modified: trunk/mailman/src/mailman/__init__.py
==============================================================================
--- trunk/mailman/src/mailman/__init__.py       (original)
+++ trunk/mailman/src/mailman/__init__.py       Sat Mar 19 17:02:47 2005
@@ -1,15 +0,0 @@
-# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software 
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Modified: trunk/mailman/src/mailman/config/__init__.py
==============================================================================
--- trunk/mailman/src/mailman/config/__init__.py        (original)
+++ trunk/mailman/src/mailman/config/__init__.py        Sat Mar 19 17:02:47 2005
@@ -37,10 +37,6 @@
 
 
 
-class Bag(object):
-    pass
-
-
 class Configuration(object):
     def set_from_options(self, options):
         self.options = options

Added: trunk/mailman/src/mailman/database/__init__.py
==============================================================================

Added: trunk/mailman/src/mailman/database/schema.py
==============================================================================
--- (empty file)
+++ trunk/mailman/src/mailman/database/schema.py        Sat Mar 19 17:02:47 2005
@@ -0,0 +1,119 @@
+# Copyright (C) 2005 Barry A. Warsaw
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place - Suite 330, Boston, MA 02111-1307, USA.
+
+"""Mailing List object schema for SQLObject."""
+
+import sys
+import logging
+
+from sqlobject import *
+from sqlobject.inheritance import InheritableSQLObject
+from sqlobject.col import *
+
+log = logging.getLogger('mailman.queues')
+
+
+
+class MailingList(SQLObject):
+    _cacheValue = False
+    # Attributes
+    name            = UnicodeCol()           # human readable name of list
+    description     = UnicodeCol()           # long descrip of list (opt)
+    owners          = ForeignKey('Roster')   # id of roster of owners
+    moderators      = ForeignKey('Roster')   # id of moderators (opt)
+    creation_date   = DateTimeCol()          # when was the list created
+    domain          = ForeignKey('Domain')   # info about the list's domain
+    members         = ForeignKey('Roster')   # id of roster of list members
+
+
+
+class Domain(SQLObject):
+    _cacheValue = False
+    # Attributes
+    mailhost    = UnicodeCol()               # hostname of mail server
+    webhost     = UnicodeCol()               # hostname of web server
+    newshost    = UnicodeCol()               # hostname of news server
+    imaphost    = UnicodeCol()               # hostname of imap server
+    admins      = ForeignKey('Roster')
+
+
+
+class Roster(SQLObject):
+    _cacheValue     = False
+    # Attributes
+    mailing_list    = ForeignKey('MailingList', default=None)
+    entries         = MultipleJoin('RosterEntry', joinColumn='member_of_id')
+
+
+class RosterEntry(InheritableSQLObject):
+    _cacheValue = False
+    # Attributes
+    member_of   = ForeignKey('Roster')
+
+
+class EmailAddress(RosterEntry):
+    _cacheValue     = False
+    _inheritable    = False
+    # Attributes
+    address             = UnicodeCol(default=None)
+    priority            = IntCol(default=None)
+    # member_id
+    is_verified         = BoolCol(default=None)
+    # preference_id
+    label               = UnicodeCol(default=None)
+    realname            = UnicodeCol(default=None)
+    registration_date   = DateTimeCol(default=None)
+    verification_date   = DateTimeCol(default=None)
+
+
+class RosterReference(RosterEntry):
+    _cacheValue     = False
+    _inheritable    = False
+    # Attributes
+    roster          = ForeignKey('Roster')
+
+
+
+if __name__ == '__main__':
+    from sqlobject.sqlite import builder
+    b = builder()
+    conn = b(sys.argv[1], debug=True)
+    for table in (MailingList, Domain, RosterEntry, EmailAddress, Roster,
+                  RosterReference):
+        table.setConnection(conn)
+        table.createTable(ifNotExists=True)
+    # Test code
+    roster1 = Roster()
+    roster2 = Roster()
+    addr1 = EmailAddress(address='[EMAIL PROTECTED]', realname='Adam Ant',
+                         member_of=roster1)
+    addr2 = EmailAddress(address='[EMAIL PROTECTED]', realname='Betty Boop',
+                         member_of=roster1)
+    addr3 = EmailAddress(address='[EMAIL PROTECTED]', realname='Charlie 
Chaplin',
+                         member_of=roster2)
+    rref = RosterReference(roster=roster2, member_of=roster1)
+
+    def dumproster(roster):
+        for entry in roster.entries:
+            if isinstance(entry, RosterReference):
+                dumproster(entry.roster)
+            else:
+                print entry.address
+
+    print 'Roster 1'
+    dumproster(roster1)
+    print 'Roster 2'
+    dumproster(roster2)
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to