[zopeorg-checkins] CVS: Products/ZWiki - SubscriberList.py:1.7
Ken Manheimer
klm at zope.com
Fri Dec 14 15:44:38 EST 2001
Update of /cvs-zopeorg/Products/ZWiki
In directory cvs.zope.org:/tmp/cvs-serv14123
Modified Files:
SubscriberList.py
Log Message:
Use a separate catalog for indexing subscriber information. Using the
main catalog is not quite proper, the subscriber info is more about
the subscriber than the content.
.subscribers_catalog: New string property which names the catalog.
.reindex_subscribers(): Reindex against the subscribers catalog when
subscriptions and unsubscriptions happen.
=== Products/ZWiki/SubscriberList.py 1.6 => 1.7 ===
-import ZWikiPage
###########################################################################
# CLASS SubscriberList
@@ -31,9 +30,14 @@
# _subscribers: {userid: [option, ...], ...}
# Empty options list mean plain subscription.
_subscribers = {}
+ subscribers_catalog = 'SubscribersIndex'
# NB this will hide the folder's subscribers property
+ _properties=(
+ {'id':'subscribers_catalog', 'type': 'string', 'mode': 'w'},
+ )
+
def _resetSubscribers(self, container=0):
"""
Clear this page's subscriber list.
@@ -142,13 +146,13 @@
subp = folder[i]
subp.subscribe(container=0, _propagating=1, sticky=1)
- self.reindex_me()
+ self.reindex_subscribers()
# redirect browser if needed
if REQUEST:
REQUEST.RESPONSE.redirect(REQUEST['URL1'] + '/subscribeform')
- def unsubscribe(self, userid=None, container=0, propagating=0,
+ def unsubscribe(self, userid=None, container=0, _propagating=0,
REQUEST=None):
"""
Remove a userid from this page's mail subscriber list.
@@ -165,18 +169,27 @@
obj._subscribers = obj._subscribers
if not container and REQUEST.get('unsubscribe_offspring'):
- if not propagating:
+ if not _propagating:
folder = self.aq_parent
for i in self.my_offspring():
subp = folder[i]
subp.unsubscribe(REQUEST=REQUEST, container=0,
- propagating=1)
+ _propagating=1)
- self.reindex_me()
+ self.reindex_subscribers()
# redirect browser if needed
if REQUEST:
REQUEST.RESPONSE.redirect(REQUEST['URL1'] + '/subscribeform')
+
+ def reindex_subscribers(self):
+ """Apply the subscribers index if we can acquare a catalog for it."""
+ if self.dont_catalog or not hasattr(self, 'REQUEST'):
+ pass
+ elif hasattr(self, self.subscribers_catalog):
+ catalog = getattr(self, self.subscribers_catalog)
+ catalog.uncatalog_object(self)
+ catalog.catalog_object(self)
######################################################################
# METHOD CATEGORY: containing folder subscription
More information about the zopeorg-checkins
mailing list