Revision: 8212
http://svn.sourceforge.net/mailman/?rev=8212&view=rev
Author: bwarsaw
Date: 2007-05-08 20:08:58 -0700 (Tue, 08 May 2007)
Log Message:
-----------
Flesh out the interface for, and doctests of the IUserManager interface and
implementation.
Modified Paths:
--------------
branches/exp-elixir-branch/Mailman/database/model/roster.py
branches/exp-elixir-branch/Mailman/database/usermanager.py
branches/exp-elixir-branch/Mailman/docs/use-listmanager.txt
branches/exp-elixir-branch/Mailman/docs/use-usermanager.txt
Modified: branches/exp-elixir-branch/Mailman/database/model/roster.py
===================================================================
--- branches/exp-elixir-branch/Mailman/database/model/roster.py 2007-05-09
01:31:36 UTC (rev 8211)
+++ branches/exp-elixir-branch/Mailman/database/model/roster.py 2007-05-09
03:08:58 UTC (rev 8212)
@@ -16,9 +16,14 @@
# USA.
from elixir import *
+from zope.interface import implements
+from Mailman.interfaces import IRoster
+
class Roster(Entity):
+ implements(IRoster)
+
with_fields(
name = Field(Unicode),
)
Modified: branches/exp-elixir-branch/Mailman/database/usermanager.py
===================================================================
--- branches/exp-elixir-branch/Mailman/database/usermanager.py 2007-05-09
01:31:36 UTC (rev 8211)
+++ branches/exp-elixir-branch/Mailman/database/usermanager.py 2007-05-09
03:08:58 UTC (rev 8212)
@@ -46,7 +46,7 @@
self.create_roster('')
def create_roster(self, name):
- roster = Roster.get_by(name)
+ roster = Roster.get_by(name=name)
if roster:
raise Errors.RosterExistsError(name)
roster = Roster(name=name)
@@ -54,11 +54,15 @@
return roster
def get_roster(self, name):
- roster = Roster.get_by(name)
+ roster = Roster.get_by(name=name)
if not roster:
raise Errors.NoSuchRosterError(name)
return roster
+ def delete_roster(self, roster):
+ roster.delete()
+ objectstore.flush()
+
@property
def rosters(self):
for roster in Roster.select():
Modified: branches/exp-elixir-branch/Mailman/docs/use-listmanager.txt
===================================================================
--- branches/exp-elixir-branch/Mailman/docs/use-listmanager.txt 2007-05-09
01:31:36 UTC (rev 8211)
+++ branches/exp-elixir-branch/Mailman/docs/use-listmanager.txt 2007-05-09
03:08:58 UTC (rev 8212)
@@ -89,7 +89,7 @@
--------------------------------
Once you've created a bunch of mailing lists, you can use the list manager to
-iterate over either the list object, or the list names.
+iterate over either the list objects, or the list names.
>>> mlist_3 = mgr.create('[EMAIL PROTECTED]')
>>> mlist_4 = mgr.create('[EMAIL PROTECTED]')
Modified: branches/exp-elixir-branch/Mailman/docs/use-usermanager.txt
===================================================================
--- branches/exp-elixir-branch/Mailman/docs/use-usermanager.txt 2007-05-09
01:31:36 UTC (rev 8211)
+++ branches/exp-elixir-branch/Mailman/docs/use-usermanager.txt 2007-05-09
03:08:58 UTC (rev 8212)
@@ -1,14 +1,97 @@
The user manager and rosters
============================
-The user manager contains a set of rosters, each roster is a collection of
-users. The user manager always contains at least one roster, the 'null'
-roster or 'all inclusive roster'.
+The IUserManager is how you create, delete, and roster objects. Rosters
+manage collections of users. The Mailman system instantiates an IUserManager
+for you based on the configuration variable MANAGERS_INIT_FUNCTION. The
+instance is accessible on the global config object.
>>> from Mailman.configuration import config
+ >>> from Mailman.interfaces import IUserManager
>>> mgr = config.user_manager
+ >>> IUserManager.providedBy(mgr)
+ True
+
+
+The default roster
+------------------
+
+The user manager always contains at least one roster, the 'null' roster or
+'all inclusive roster'.
+
>>> sorted(roster.name for roster in mgr.rosters)
['']
-Users can belong to more than one roster, but the belong to at least
-one roster, the null roster. The null roster returns all the users
\ No newline at end of file
+
+Adding rosters
+--------------
+
+You create a roster to hold users. The only thing a roster needs is a name,
+basically just an identifying string.
+
+ >>> from Mailman.interfaces import IRoster
+ >>> roster = mgr.create_roster('roster-1')
+ >>> IRoster.providedBy(roster)
+ True
+ >>> roster.name
+ 'roster-1'
+
+If you try to create a roster with the same name as an existing roster, you
+will get an exception.
+
+ >>> roster_dup = mgr.create_roster('roster-1')
+ Traceback (most recent call last):
+ ...
+ RosterExistsError: roster-1
+
+
+Deleting a roster
+-----------------
+
+Delete the roster, and you can then create it again.
+
+ >>> mgr.delete_roster(roster)
+ >>> roster = mgr.create_roster('roster-1')
+ >>> roster.name
+ 'roster-1'
+
+Retrieving a roster
+-------------------
+
+When a roster exists, you can ask the user manager for it and you will always
+get the same object back.
+
+ >>> roster_2 = mgr.get_roster('roster-1')
+ >>> roster_2.name
+ 'roster-1'
+ >>> roster is roster_2
+ True
+
+Don't try to get a roster that doesn't exist yet though, or you will get an
+exception.
+
+ >>> mgr.get_roster('no roster')
+ Traceback (most recent call last):
+ ...
+ NoSuchRosterError: no roster
+
+
+Iterating over all the rosters
+------------------------------
+
+Once you've created a bunch of rosters, you can use the user manager to
+iterate over all the rosters.
+
+ >>> roster_2 = mgr.create_roster('roster-2')
+ >>> roster_3 = mgr.create_roster('roster-3')
+ >>> roster_4 = mgr.create_roster('roster-4')
+ >>> sorted(roster.name for roster in mgr.rosters)
+ ['', 'roster-1', 'roster-2', 'roster-3', 'roster-4']
+
+
+Cleaning up
+-----------
+
+ >>> for roster in mgr.rosters:
+ ... mgr.delete_roster(roster)
+
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org