From 18e07a3dc2caa61ed042515cd91833a76a596b9d Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 19 Sep 2007 22:35:37 -0400 Subject: InitTempVars() is completely eradicated. The only bit I think we still need temporarily is the _gui component initialization, so this has been moved into MailList.__init__(). Fixed the __getattr__() super call to properly dispatch up. Removed the _memberadaptor instance variable initialization. The whole MemberAdaptor stuff is next on the chopping block. Essentially MailList locking is gone too now, although it's not yet completely eradicated. However, the __repr__() no longer states the lock status. The full_path property is now just an attribute on the underlying MailingList database object. --- Mailman/MailList.py | 68 +++++------------------------------ Mailman/database/model/mailinglist.py | 6 +++- Mailman/docs/hold.txt | 7 ---- Mailman/docs/membership.txt | 2 +- Mailman/docs/requests.txt | 2 +- TODO.txt | 1 - 6 files changed, 16 insertions(+), 70 deletions(-) diff --git a/Mailman/MailList.py b/Mailman/MailList.py index 70ae98067..84b098ae6 100644 --- a/Mailman/MailList.py +++ b/Mailman/MailList.py @@ -97,12 +97,16 @@ class MailList(object, HTMLFormatter, Deliverer, def __init__(self, data): self._data = data - # Only one level of mixin inheritance allowed + # Only one level of mixin inheritance allowed. for baseclass in self.__class__.__bases__: if hasattr(baseclass, '__init__'): baseclass.__init__(self) - # Initialize volatile attributes - self.InitTempVars() + # Initialize the web u/i components. + self._gui = [] + for component in dir(Gui): + if component.startswith('_'): + continue + self._gui.append(getattr(Gui, component)()) # Give the extension mechanism a chance to process this list. try: from Mailman.ext import init_mlist @@ -114,13 +118,9 @@ class MailList(object, HTMLFormatter, Deliverer, def __getattr__(self, name): missing = object() if name.startswith('_'): - return super(MailList, self).__getattr__(name) + return getattr(super(MailList, self), name) # Delegate to the database model object if it has the attribute. obj = getattr(self._data, name, missing) - if obj is not missing: - return obj - # Delegate to the member adapter next. - obj = getattr(self._memberadaptor, name, missing) if obj is not missing: return obj # Finally, delegate to one of the gui components. @@ -132,12 +132,7 @@ class MailList(object, HTMLFormatter, Deliverer, raise AttributeError(name) def __repr__(self): - if self.Locked(): - status = '(locked)' - else: - status = '(unlocked)' - return '' % ( - self.fqdn_listname, status, id(self)) + return '' % (self.fqdn_listname, id(self)) # @@ -169,15 +164,6 @@ class MailList(object, HTMLFormatter, Deliverer, return self._lock.locked() - - # - # Useful accessors - # - @property - def full_path(self): - return self._full_path - - # IMailingListAddresses @@ -276,42 +262,6 @@ class MailList(object, HTMLFormatter, Deliverer, user = Utils.ObscureEmail(user) return '%s/%s' % (url, urllib.quote(user.lower())) - - # - # Instance and subcomponent initialization - # - def InitTempVars(self): - """Set transient variables of this and inherited classes.""" - # Because of the semantics of the database layer, it's possible that - # this method gets called more than once on an existing object. For - # example, if the MailList object is expunged from the current db - # session, then this may get called again when the object's persistent - # attributes are re-read from the database. This can have nasty - # consequences, so ensure that we're only called once. - if hasattr(self, '_lock'): - return - # Attach a membership adaptor instance. - parts = config.MEMBER_ADAPTOR_CLASS.split(DOT) - adaptor_class = parts.pop() - adaptor_module = DOT.join(parts) - __import__(adaptor_module) - mod = sys.modules[adaptor_module] - self._memberadaptor = getattr(mod, adaptor_class)(self) - self._make_lock(self.fqdn_listname) - # Create the list's data directory. - self._full_path = os.path.join(config.LIST_DATA_DIR, self.fqdn_listname) - Utils.makedirs(self._full_path) - # Only one level of mixin inheritance allowed - for baseclass in self.__class__.__bases__: - if hasattr(baseclass, 'InitTempVars'): - baseclass.InitTempVars(self) - # Now, initialize our gui components - self._gui = [] - for component in dir(Gui): - if component.startswith('_'): - continue - self._gui.append(getattr(Gui, component)()) - # # Web API support via administrative categories diff --git a/Mailman/database/model/mailinglist.py b/Mailman/database/model/mailinglist.py index 0cb968574..1b2892a46 100644 --- a/Mailman/database/model/mailinglist.py +++ b/Mailman/database/model/mailinglist.py @@ -15,10 +15,12 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. +import os + from elixir import * from zope.interface import implements -from Mailman.Utils import fqdn_listname, split_listname +from Mailman.Utils import fqdn_listname, makedirs, split_listname from Mailman.configuration import config from Mailman.interfaces import * from Mailman.database.types import EnumType, TimeDeltaType @@ -174,6 +176,8 @@ class MailingList(Entity): # 2-tuple of the date of the last autoresponse and the number of # autoresponses sent on that date. self.hold_and_cmd_autoresponses = {} + self.full_path = os.path.join(config.LIST_DATA_DIR, fqdn_listname) + makedirs(self.full_path) # XXX FIXME def _restore(self): diff --git a/Mailman/docs/hold.txt b/Mailman/docs/hold.txt index 906053df4..62b621bdc 100644 --- a/Mailman/docs/hold.txt +++ b/Mailman/docs/hold.txt @@ -19,12 +19,6 @@ are held when they meet any of a number of criteria. >>> mlist._data.web_page_url = 'http://lists.example.com/' >>> flush() -XXX The Hold handler requires that the mailing list be locked because it -touches the pending database. Eventually the pending database should be moved -into the real database so that the lock is no longer necessary. - - >>> mlist.Lock() - Here's a helper function used when we don't care about what's in the virgin queue or in the pending database. @@ -380,4 +374,3 @@ The message itself is held in the message store. Clean up. >>> clear() - >>> mlist.Unlock() diff --git a/Mailman/docs/membership.txt b/Mailman/docs/membership.txt index 515ac7623..6c0a209e7 100644 --- a/Mailman/docs/membership.txt +++ b/Mailman/docs/membership.txt @@ -19,7 +19,7 @@ When we create a mailing list, it starts out with no members... >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> flush() >>> mlist - + >>> sorted(member.address.address for member in mlist.members.members) [] >>> sorted(user.real_name for user in mlist.members.users) diff --git a/Mailman/docs/requests.txt b/Mailman/docs/requests.txt index 242d57b9c..e513b7cea 100644 --- a/Mailman/docs/requests.txt +++ b/Mailman/docs/requests.txt @@ -48,7 +48,7 @@ mailing list you need to get its requests object. >>> verifyObject(IListRequests, requests) True >>> requests.mailing_list - + Holding requests diff --git a/TODO.txt b/TODO.txt index 365db3c32..87cffee07 100644 --- a/TODO.txt +++ b/TODO.txt @@ -3,7 +3,6 @@ things that I need to do. Fix the XXX in model/requests.py where we need a flush because we can't get to last_inserted_id() -Get rid of InitTempVars() Get rid of PickleTypes Get rid of MailList class! Add tests for bin/newlist and bin/rmlist -- cgit v1.3.1