PageRenderTime 107ms CodeModel.GetById 22ms RepoModel.GetById 2ms app.codeStats 0ms

/tags/pre-i18n/mailman/Mailman/MailList.py

#
Python | 1274 lines | 1132 code | 42 blank | 100 comment | 98 complexity | 943378bd1ecf1158caeaa2d3f58f5c46 MD5 | raw file
Possible License(s): GPL-2.0
  1. # Copyright (C) 1998 by the Free Software Foundation, Inc.
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software
  15. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. """The class representing a Mailman mailing list.
  17. Mixes in many task-specific classes.
  18. """
  19. import sys
  20. import os
  21. import marshal
  22. import string
  23. import errno
  24. import re
  25. from types import StringType, IntType, DictType
  26. from Mailman import mm_cfg
  27. from Mailman import Utils
  28. from Mailman import Errors
  29. from Mailman import LockFile
  30. # base classes
  31. from Mailman.ListAdmin import ListAdmin
  32. from Mailman.Deliverer import Deliverer
  33. from Mailman.MailCommandHandler import MailCommandHandler
  34. from Mailman.HTMLFormatter import HTMLFormatter
  35. from Mailman.Archiver import Archiver
  36. from Mailman.Digester import Digester
  37. from Mailman.SecurityManager import SecurityManager
  38. from Mailman.Bouncer import Bouncer
  39. from Mailman.GatewayManager import GatewayManager
  40. from Mailman.Logging.StampedLogger import StampedLogger
  41. # other useful classes
  42. from Mailman.pythonlib.StringIO import StringIO
  43. from Mailman import Message
  44. from Mailman.Handlers import HandlerAPI
  45. # Note:
  46. # an _ in front of a member variable for the MailList class indicates
  47. # a variable that does not save when we marshal our state.
  48. # Use mixins here just to avoid having any one chunk be too large.
  49. class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin,
  50. Archiver, Digester, SecurityManager, Bouncer, GatewayManager):
  51. def __init__(self, name=None, lock=1):
  52. if name and name not in Utils.list_names():
  53. raise Errors.MMUnknownListError, 'list not found: %s' % name
  54. MailCommandHandler.__init__(self)
  55. self.InitTempVars(name, lock)
  56. if name:
  57. self.Load()
  58. def __del__(self):
  59. try:
  60. for f in self._log_files.values():
  61. f.close()
  62. except AttributeError:
  63. # List didn't get far enough to have _log_files
  64. pass
  65. try:
  66. self.Unlock()
  67. except AttributeError:
  68. # List didn't get far enough to have __lock
  69. pass
  70. def GetMembers(self):
  71. """returns a list of the members. (all lowercase)"""
  72. return self.members.keys()
  73. def GetDigestMembers(self):
  74. """returns a list of digest members. (all lowercase)"""
  75. return self.digest_members.keys()
  76. def GetDeliveryMembers(self):
  77. """returns a list of the members with username case preserved."""
  78. res = []
  79. for k, v in self.members.items():
  80. if type(v) is StringType:
  81. res.append(v)
  82. else:
  83. res.append(k)
  84. return res
  85. def GetDigestDeliveryMembers(self):
  86. """returns a list of the members with username case preserved."""
  87. res = []
  88. for k,v in self.digest_members.items():
  89. if type(v) is StringType:
  90. res.append(v)
  91. else:
  92. res.append(k)
  93. return res
  94. def __AddMember(self, addr, digest):
  95. """adds the appropriate data to the internal members dict.
  96. If the username has upercase letters in it, then the value
  97. in the members dict is the case preserved address, otherwise,
  98. the value is 0.
  99. """
  100. if Utils.LCDomain(addr) == string.lower(addr):
  101. if digest:
  102. self.digest_members[addr] = 0
  103. else:
  104. self.members[addr] = 0
  105. else:
  106. if digest:
  107. self.digest_members[string.lower(addr)] = addr
  108. else:
  109. self.members[string.lower(addr)] = addr
  110. def GetAdminEmail(self):
  111. return '%s-admin@%s' % (self._internal_name, self.host_name)
  112. def GetMemberAdminEmail(self, member):
  113. """Usually the member addr, but modified for umbrella lists.
  114. Umbrella lists have other mailing lists as members, and so admin stuff
  115. like confirmation requests and passwords must not be sent to the
  116. member addresses - the sublists - but rather to the administrators of
  117. the sublists. This routine picks the right address, considering
  118. regular member address to be their own administrative addresses.
  119. """
  120. if not self.umbrella_list:
  121. return member
  122. else:
  123. acct, host = tuple(string.split(member, '@'))
  124. return "%s%s@%s" % (acct, self.umbrella_member_suffix, host)
  125. def GetUserSubscribedAddress(self, member):
  126. """Return the member's case preserved address.
  127. """
  128. member = string.lower(member)
  129. cpuser = self.members.get(member)
  130. if type(cpuser) == IntType:
  131. return member
  132. elif type(cpuser) == StringType:
  133. return cpuser
  134. cpuser = self.digest_members.get(member)
  135. if type(cpuser) == IntType:
  136. return member
  137. elif type(cpuser) == StringType:
  138. return cpuser
  139. return None
  140. def GetUserCanonicalAddress(self, member):
  141. """Return the member's address lower cased."""
  142. cpuser = self.GetUserSubscribedAddress(member)
  143. if cpuser is not None:
  144. return string.lower(cpuser)
  145. return None
  146. def GetRequestEmail(self):
  147. return '%s-request@%s' % (self._internal_name, self.host_name)
  148. def GetListEmail(self):
  149. return '%s@%s' % (self._internal_name, self.host_name)
  150. def GetListIdentifier(self):
  151. """Return the unique (RFC draft-chandhok-listid-02) identifier."""
  152. return ("%s <%s.%s>" %
  153. (self.description, self._internal_name, self.host_name))
  154. def GetScriptURL(self, scriptname, relative=0):
  155. if relative:
  156. prefix = '../' * Utils.GetNestingLevel()
  157. elif self.web_page_url:
  158. prefix = self.web_page_url
  159. else:
  160. prefix = mm_cfg.DEFAULT_URL
  161. i = len(prefix)-1
  162. while i >= 0 and prefix[i] == '/':
  163. i = i - 1
  164. prefix = prefix[:i+1]
  165. return '%s/%s%s/%s' % (prefix, scriptname, mm_cfg.CGIEXT,
  166. self.internal_name())
  167. def GetOptionsURL(self, addr, obscure=0, relative=0):
  168. addr = string.lower(addr)
  169. url = self.GetScriptURL('options', relative)
  170. if obscure:
  171. addr = Utils.ObscureEmail(addr)
  172. return '%s/%s' % (url, addr)
  173. # TBD: backwards compatibility. We should really just fix the code
  174. GetAbsoluteOptionsURL = GetOptionsURL
  175. GetAbsoluteScriptURL = GetScriptURL
  176. def GetRelativeScriptURL(self, scriptname):
  177. return self.GetScriptURL(scriptname, relative=1)
  178. def GetUserOption(self, user, option):
  179. """Return user's setting for option, defaulting to 0 if no settings."""
  180. user = self.GetUserCanonicalAddress(user)
  181. if option == mm_cfg.Digests:
  182. return self.digest_members.has_key(user)
  183. if not self.user_options.has_key(user):
  184. return 0
  185. return not not self.user_options[user] & option
  186. def SetUserOption(self, user, option, value, save_list=1):
  187. user = self.GetUserCanonicalAddress(user)
  188. if not self.user_options.has_key(user):
  189. self.user_options[user] = 0
  190. if value:
  191. self.user_options[user] = self.user_options[user] | option
  192. else:
  193. self.user_options[user] = self.user_options[user] & ~(option)
  194. if not self.user_options[user]:
  195. del self.user_options[user]
  196. if save_list:
  197. self.Save()
  198. # Here are the rules for the three dictionaries self.members,
  199. # self.digest_members, and self.passwords:
  200. #
  201. # The keys of all these dictionaries are the lowercased version of the
  202. # address. This makes finding a user very quick: just lowercase the name
  203. # you're matching against, and do a has_key() or get() on first
  204. # self.members, then if that returns false, self.digest_members
  205. #
  206. # The value of the key in self.members and self.digest_members is either
  207. # the integer 0, meaning the user was subscribed with an all-lowercase
  208. # address, or a string which would be the address with the username part
  209. # case preserved. Note that for Mailman versions before 1.0b11, the value
  210. # could also have been the integer 1. This is a bug that was caused when
  211. # a user switched from regular to/from digest membership. If this
  212. # happened, you're screwed because there's no way to recover the case
  213. # preserved address. :-(
  214. #
  215. # The keys for self.passwords is also lowercase, although for versions of
  216. # Mailman before 1.0b11, this was not always true. 1.0b11 has a hack in
  217. # Load() that forces the keys to lowercase. The value for the keys in
  218. # self.passwords is, of course the password in plain text.
  219. def FindUser(self, email):
  220. """Return the lowercased version of the subscribed email address.
  221. If email is not subscribed, either as a regular member or digest
  222. member, None is returned. If they are subscribed, the return value is
  223. guaranteed to be lowercased.
  224. """
  225. # shortcut
  226. lcuser = self.GetUserCanonicalAddress(email)
  227. if lcuser is not None:
  228. return lcuser
  229. matches = Utils.FindMatchingAddresses(email,
  230. self.members,
  231. self.digest_members)
  232. # sadly, matches may or may not be case preserved
  233. if not matches or not len(matches):
  234. return None
  235. return string.lower(matches[0])
  236. def InitTempVars(self, name, lock):
  237. """Set transient variables of this and inherited classes."""
  238. self.__createlock_p = lock
  239. self.__lock = LockFile.LockFile(
  240. os.path.join(mm_cfg.LOCK_DIR, name or '<site>') + '.lock',
  241. # TBD: is this a good choice of lifetime?
  242. lifetime = 60,
  243. withlogging=1)
  244. self._internal_name = name
  245. self._ready = 0
  246. self._log_files = {} # 'class': log_file_obj
  247. if name:
  248. self._full_path = os.path.join(mm_cfg.LIST_DATA_DIR, name)
  249. else:
  250. self._full_path = None
  251. ListAdmin.InitTempVars(self)
  252. def InitVars(self, name=None, admin='', crypted_password=''):
  253. """Assign default values - some will be overriden by stored state."""
  254. # Non-configurable list info
  255. if name:
  256. self._internal_name = name
  257. # Must save this state, even though it isn't configurable
  258. self.volume = 1
  259. self.members = {} # self.digest_members is initted in mm_digest
  260. self.data_version = mm_cfg.VERSION
  261. self.last_post_time = 0
  262. self.post_id = 1. # A float so it never has a chance to overflow.
  263. self.user_options = {}
  264. # This stuff is configurable
  265. self.filter_prog = mm_cfg.DEFAULT_FILTER_PROG
  266. self.dont_respond_to_post_requests = 0
  267. self.num_spawns = mm_cfg.DEFAULT_NUM_SPAWNS
  268. self.advertised = mm_cfg.DEFAULT_LIST_ADVERTISED
  269. self.max_num_recipients = mm_cfg.DEFAULT_MAX_NUM_RECIPIENTS
  270. self.max_message_size = mm_cfg.DEFAULT_MAX_MESSAGE_SIZE
  271. self.web_page_url = mm_cfg.DEFAULT_URL
  272. self.owner = [admin]
  273. self.reply_goes_to_list = mm_cfg.DEFAULT_REPLY_GOES_TO_LIST
  274. self.posters = []
  275. self.forbidden_posters = []
  276. self.admin_immed_notify = mm_cfg.DEFAULT_ADMIN_IMMED_NOTIFY
  277. self.admin_notify_mchanges = \
  278. mm_cfg.DEFAULT_ADMIN_NOTIFY_MCHANGES
  279. self.moderated = mm_cfg.DEFAULT_MODERATED
  280. self.require_explicit_destination = \
  281. mm_cfg.DEFAULT_REQUIRE_EXPLICIT_DESTINATION
  282. self.acceptable_aliases = mm_cfg.DEFAULT_ACCEPTABLE_ALIASES
  283. self.umbrella_list = mm_cfg.DEFAULT_UMBRELLA_LIST
  284. self.umbrella_member_suffix = \
  285. mm_cfg.DEFAULT_UMBRELLA_MEMBER_ADMIN_SUFFIX
  286. self.send_reminders = mm_cfg.DEFAULT_SEND_REMINDERS
  287. self.send_welcome_msg = mm_cfg.DEFAULT_SEND_WELCOME_MSG
  288. self.bounce_matching_headers = \
  289. mm_cfg.DEFAULT_BOUNCE_MATCHING_HEADERS
  290. self.anonymous_list = mm_cfg.DEFAULT_ANONYMOUS_LIST
  291. self.real_name = '%s%s' % (string.upper(self._internal_name[0]),
  292. self._internal_name[1:])
  293. self.description = ''
  294. self.info = ''
  295. self.welcome_msg = ''
  296. self.goodbye_msg = ''
  297. self.subscribe_policy = mm_cfg.DEFAULT_SUBSCRIBE_POLICY
  298. self.private_roster = mm_cfg.DEFAULT_PRIVATE_ROSTER
  299. self.obscure_addresses = mm_cfg.DEFAULT_OBSCURE_ADDRESSES
  300. self.member_posting_only = mm_cfg.DEFAULT_MEMBER_POSTING_ONLY
  301. self.host_name = mm_cfg.DEFAULT_HOST_NAME
  302. self.admin_member_chunksize = mm_cfg.DEFAULT_ADMIN_MEMBER_CHUNKSIZE
  303. # Analogs to these are initted in Digester.InitVars
  304. self.nondigestable = mm_cfg.DEFAULT_NONDIGESTABLE
  305. Digester.InitVars(self) # has configurable stuff
  306. SecurityManager.InitVars(self, crypted_password)
  307. Archiver.InitVars(self) # has configurable stuff
  308. ListAdmin.InitVars(self)
  309. Bouncer.InitVars(self)
  310. GatewayManager.InitVars(self)
  311. HTMLFormatter.InitVars(self)
  312. # These need to come near the bottom because they're dependent on
  313. # other settings.
  314. self.subject_prefix = mm_cfg.DEFAULT_SUBJECT_PREFIX % self.__dict__
  315. self.msg_header = mm_cfg.DEFAULT_MSG_HEADER
  316. self.msg_footer = mm_cfg.DEFAULT_MSG_FOOTER
  317. def GetConfigInfo(self):
  318. config_info = {}
  319. config_info['digest'] = Digester.GetConfigInfo(self)
  320. config_info['archive'] = Archiver.GetConfigInfo(self)
  321. config_info['gateway'] = GatewayManager.GetConfigInfo(self)
  322. # XXX: Should this text be migrated into the templates dir?
  323. config_info['general'] = [
  324. "Fundamental list characteristics, including descriptive"
  325. " info and basic behaviors.",
  326. ('real_name', mm_cfg.String, 50, 0,
  327. 'The public name of this list (make case-changes only).',
  328. "The capitalization of this name can be changed to make it"
  329. " presentable in polite company as a proper noun, or to make an"
  330. " acronym part all upper case, etc. However, the name"
  331. " will be advertised as the email address (e.g., in subscribe"
  332. " confirmation notices), so it should <em>not</em> be otherwise"
  333. " altered. (Email addresses are not case sensitive, but"
  334. " they are sensitive to almost everything else:-)"),
  335. ('owner', mm_cfg.EmailList, (3,30), 0,
  336. "The list admin's email address - having multiple"
  337. " admins/addresses (on separate lines) is ok."),
  338. ('description', mm_cfg.String, 50, 0,
  339. 'A terse phrase identifying this list.',
  340. "This description is used when the mailing list is listed with"
  341. " other mailing lists, or in headers, and so forth. It should"
  342. " be as succinct as you can get it, while still identifying"
  343. " what the list is."),
  344. ('info', mm_cfg.Text, (7, 50), 0,
  345. ' An introductory description - a few paragraphs - about the'
  346. ' list. It will be included, as html, at the top of the'
  347. ' listinfo page. Carriage returns will end a paragraph - see'
  348. ' the details for more info.',
  349. "The text will be treated as html <em>except</em> that newlines"
  350. " newlines will be translated to &lt;br&gt; - so you can use"
  351. " links, preformatted text, etc, but don't put in carriage"
  352. " returns except where you mean to separate paragraphs. And"
  353. " review your changes - bad html (like some unterminated HTML"
  354. " constructs) can prevent display of the entire listinfo page."),
  355. ('subject_prefix', mm_cfg.String, 10, 0,
  356. 'Prefix for subject line of list postings.',
  357. "This text will be prepended to subject lines of messages"
  358. " posted to the list, to distinguish mailing list messages in"
  359. " in mailbox summaries. Brevity is premium here, it's ok"
  360. " to shorten long mailing list names to something more concise,"
  361. " as long as it still identifies the mailing list."),
  362. ('welcome_msg', mm_cfg.Text, (4, 50), 0,
  363. 'List-specific text prepended to new-subscriber welcome message',
  364. "This value, if any, will be added to the front of the"
  365. " new-subscriber welcome message. The rest of the"
  366. " welcome message already describes the important addresses"
  367. " and URLs for the mailing list, so you don't need to include"
  368. " any of that kind of stuff here. This should just contain"
  369. " mission-specific kinds of things, like etiquette policies"
  370. " or team orientation, or that kind of thing."),
  371. ('goodbye_msg', mm_cfg.Text, (4, 50), 0,
  372. 'Text sent to people leaving the list. If empty, no special'
  373. ' text will be added to the unsubscribe message.'),
  374. ('reply_goes_to_list', mm_cfg.Radio, ('Poster', 'List'), 0,
  375. 'Are replies to a post directed to the original poster'
  376. ' or to the list? <tt>Poster</tt> is <em>strongly</em>'
  377. ' recommended.',
  378. "There are many reasons not to introduce headers like reply-to"
  379. " into other peoples messages - one is that some posters depend"
  380. " on their own reply-to setting to convey their valid email"
  381. " addr. See"
  382. ' <a href="http://www.unicom.com/pw/reply-to-harmful.html">'
  383. '"Reply-To" Munging Considered Harmful</a> for a general.'
  384. " discussion of this issue."),
  385. ('administrivia', mm_cfg.Radio, ('No', 'Yes'), 0,
  386. "(Administrivia filter) Check postings and intercept ones"
  387. " that seem to be administrative requests?",
  388. "Administrivia tests will check postings to see whether"
  389. " it's really meant as an administrative request (like"
  390. " subscribe, unsubscribe, etc), and will add it to the"
  391. " the administrative requests queue, notifying the "
  392. " administrator of the new request, in the process. "),
  393. ('umbrella_list', mm_cfg.Radio, ('No', 'Yes'), 0,
  394. 'Send password reminders to, eg, "-owner" address instead of'
  395. ' directly to user.',
  396. "Set this to yes when this list is intended to cascade only to"
  397. " other mailing lists. When set, meta notices like confirmations"
  398. " and password reminders will be directed to an address derived"
  399. " from the member\'s address - it will have the value of"
  400. ' \"umbrella_member_suffix\" appended to the'
  401. " member\'s account name."),
  402. ('umbrella_member_suffix', mm_cfg.String, 8, 0,
  403. 'Suffix for use when this list is an umbrella for other lists,'
  404. ' according to setting of previous "umbrella_list" setting.',
  405. 'When \"umbrella_list\" is set to indicate that this list has'
  406. " other mailing lists as members, then administrative notices"
  407. " like confirmations and password reminders need to not be sent"
  408. " to the member list addresses, but rather to the owner of those"
  409. " member lists. In that case, the value of this setting is"
  410. " appended to the member\'s account name for such notices."
  411. " \'-owner\' is the typical choice. This setting has no"
  412. ' effect when \"umbrella_list\" is \"No\".'),
  413. ('send_reminders', mm_cfg.Radio, ('No', 'Yes'), 0,
  414. 'Send monthly password reminders or no? Overrides the previous '
  415. 'option.'),
  416. ('send_welcome_msg', mm_cfg.Radio, ('No', 'Yes'), 0,
  417. 'Send welcome message when people subscribe?',
  418. "Turn this on only if you plan on subscribing people manually "
  419. "and don't want them to know that you did so. This option "
  420. "is most useful for transparently migrating lists from "
  421. "some other mailing list manager to Mailman."),
  422. ('admin_immed_notify', mm_cfg.Radio, ('No', 'Yes'), 0,
  423. 'Should administrator get immediate notice of new requests, '
  424. 'as well as daily notices about collected ones?',
  425. "List admins are sent daily reminders of pending admin approval"
  426. " requests, like subscriptions to a moderated list or postings"
  427. " that are being held for one reason or another. Setting this"
  428. " option causes notices to be sent immediately on the arrival"
  429. " of new requests, as well."),
  430. ('admin_notify_mchanges', mm_cfg.Radio, ('No', 'Yes'), 0,
  431. 'Should administrator get notices of subscribes/unsubscribes?'),
  432. ('dont_respond_to_post_requests', mm_cfg.Radio, ('Yes', 'No'), 0,
  433. 'Send mail to poster when their posting is held for approval?',
  434. "Approval notices are sent when mail triggers certain of the"
  435. " limits <em>except</em> routine list moderation and spam"
  436. " filters, for which notices are <em>not</em> sent. This"
  437. " option overrides ever sending the notice."),
  438. ('max_message_size', mm_cfg.Number, 5, 0,
  439. 'Maximum length in Kb of a message body. Use 0 for no limit.'),
  440. ('num_spawns', mm_cfg.Number, 3, 0,
  441. 'Number of outgoing connections to open at once '
  442. '(expert users only).',
  443. "This determines the maximum number of batches into which"
  444. " a mass posting will be divided."),
  445. ('host_name', mm_cfg.Host, 50, 0, 'Host name this list prefers.',
  446. "The host_name is the preferred name for email to mailman-related"
  447. " addresses on this host, and generally should be the mail"
  448. " host's exchanger address, if any. This setting can be useful"
  449. " for selecting among alternative names of a host that has"
  450. " multiple addresses."),
  451. ('web_page_url', mm_cfg.String, 50, 0,
  452. 'Base URL for Mailman web interface',
  453. "This is the common root for all mailman URLs concerning this"
  454. " list. It is also used in the listinfo overview of mailing"
  455. " lists"
  456. " to identify whether or not this list resides on the virtual"
  457. " host identified by the overview URL - if this value is found"
  458. " (anywhere) in the URL, then this list is considered to be"
  459. " on that virtual host, and if not, then it is excluded from"
  460. " the listing. Note that you should use the \'advertised\'"
  461. " privacy option to inhibit any listing of the host."),
  462. ]
  463. if mm_cfg.ALLOW_OPEN_SUBSCRIBE:
  464. sub_cfentry = ('subscribe_policy', mm_cfg.Radio,
  465. ('none', 'confirm', 'require approval',
  466. 'confirm+approval'), 0,
  467. "What steps are required for subscription?<br>",
  468. "None - no verification steps (<em>Not"
  469. " Recommended </em>)<br>"
  470. "confirm (*) - email confirmation step"
  471. " required <br>"
  472. "require approval - require list administrator"
  473. " approval for subscriptions <br>"
  474. "confirm+approval - both confirm and approve"
  475. "<p> (*) when someone requests a subscription,"
  476. " mailman sends them a notice with a unique"
  477. " subscription request number that they must"
  478. " reply to in order to subscribe.<br> This"
  479. " prevents mischievous (or malicious) people"
  480. " from creating subscriptions for others"
  481. " without their consent."
  482. )
  483. else:
  484. sub_cfentry = ('subscribe_policy', mm_cfg.Radio,
  485. ('confirm', 'require approval',
  486. 'confirm+approval'), 1,
  487. "What steps are required for subscription?<br>",
  488. "confirm (*) - email confirmation required <br>"
  489. "require approval - require list administrator"
  490. " approval for subscriptions <br>"
  491. "confirm+approval - both confirm and approve"
  492. "<p> (*) when someone requests a subscription,"
  493. " mailman sends them a notice with a unique"
  494. " subscription request number that they must"
  495. " reply to in order to subscribe.<br> This"
  496. " prevents mischievous (or malicious) people"
  497. " from creating subscriptions for others"
  498. " without their consent."
  499. )
  500. config_info['privacy'] = [
  501. "List access policies, including anti-spam measures,"
  502. " covering members and outsiders."
  503. ' (See also the <a href="%s/archive">Archival Options'
  504. ' section</a> for separate archive-privacy settings.)'
  505. % (self.GetRelativeScriptURL('admin')),
  506. "Subscribing",
  507. ('advertised', mm_cfg.Radio, ('No', 'Yes'), 0,
  508. 'Advertise this list when people ask what lists are on '
  509. 'this machine?'),
  510. sub_cfentry,
  511. "Membership exposure",
  512. ('private_roster', mm_cfg.Radio,
  513. ('Anyone', 'List members', 'List admin only'), 0,
  514. 'Who can view subscription list?',
  515. "When set, the list of subscribers is protected by"
  516. " member or admin password authentication."),
  517. ('obscure_addresses', mm_cfg.Radio, ('No', 'Yes'), 0,
  518. "Show member addrs so they're not directly recognizable"
  519. ' as email addrs?',
  520. "Setting this option causes member email addresses to be"
  521. " transformed when they are presented on list web pages (both"
  522. " in text and as links), so they're not trivially"
  523. " recognizable as email addresses. The intention is to"
  524. " to prevent the addresses from being snarfed up by"
  525. " automated web scanners for use by spammers."),
  526. "General posting filters",
  527. ('moderated', mm_cfg.Radio, ('No', 'Yes'), 0,
  528. 'Must posts be approved by an administrator?'),
  529. ('member_posting_only', mm_cfg.Radio, ('No', 'Yes'), 0,
  530. 'Restrict posting privilege to list members?'
  531. ' (<i>member_posting_only</i>)',
  532. "Use this option if you want to restrict posting to list members."
  533. " If you want list members to be able to"
  534. " post, plus a handful of other posters, see the <i> posters </i>"
  535. " setting below"),
  536. ('posters', mm_cfg.EmailList, (5, 30), 1,
  537. 'Addresses of members accepted for posting to this'
  538. ' list without implicit approval requirement. (See'
  539. ' "Restrict ... to list members"'
  540. ' for whether or not this is in addition to allowing posting'
  541. ' by list members',
  542. "Adding entries here will have one of two effects,"
  543. " according to whether another option restricts posting to"
  544. " members. <ul>"
  545. " <li> If <i>member_posting_only</i> is 'yes', then entries"
  546. " added here will have posting privilege in addition to"
  547. " list members."
  548. " <li> If <i>member_posting_only</i> is 'no', then <em>only</em>"
  549. " the posters listed here will be able to post without admin"
  550. " approval. </ul>"),
  551. "Spam-specific posting filters",
  552. ('require_explicit_destination', mm_cfg.Radio, ('No', 'Yes'), 0,
  553. 'Must posts have list named in destination (to, cc) field'
  554. ' (or be among the acceptable alias names, specified below)?',
  555. "Many (in fact, most) spams do not explicitly name their myriad"
  556. " destinations in the explicit destination addresses - in fact,"
  557. " often the to field has a totally bogus address for"
  558. " obfuscation. The constraint applies only to the stuff in"
  559. " the address before the '@' sign, but still catches all such"
  560. " spams."
  561. "<p>The cost is that the list will not accept unhindered any"
  562. " postings relayed from other addresses, unless <ol>"
  563. " <li>The relaying address has the same name, or"
  564. " <li>The relaying address name is included on the options that"
  565. " specifies acceptable aliases for the list. </ol>"),
  566. ('acceptable_aliases', mm_cfg.Text, ('4', '30'), 0,
  567. 'Alias names (regexps) which qualify as explicit to or cc'
  568. ' destination names for this list.',
  569. "Alternate list names (the stuff before the '@') that are to be"
  570. " accepted when the explicit-destination constraint (a prior"
  571. " option) is active. This enables things like cascading"
  572. " mailing lists and relays while the constraint is still"
  573. " preventing random spams."),
  574. ('max_num_recipients', mm_cfg.Number, 3, 0,
  575. 'Ceiling on acceptable number of recipients for a posting.',
  576. "If a posting has this number, or more, of recipients, it is"
  577. " held for admin approval. Use 0 for no ceiling."),
  578. ('forbidden_posters', mm_cfg.EmailList, (5, 30), 1,
  579. 'Addresses whose postings are always held for approval.',
  580. "Email addresses whose posts should always be held for"
  581. " approval, no matter what other options you have set."
  582. " See also the subsequent option which applies to arbitrary"
  583. " content of arbitrary headers."),
  584. ('bounce_matching_headers', mm_cfg.Text, ('6', '50'), 0,
  585. 'Hold posts with header value matching a specified regexp.',
  586. "Use this option to prohibit posts according to specific header"
  587. " values. The target value is a regular-expression for"
  588. " matching against the specified header. The match is done"
  589. " disregarding letter case. Lines beginning with '#' are"
  590. " ignored as comments."
  591. "<p>For example:<pre>to: .*@public.com </pre> says"
  592. " to hold all postings with a <em>to</em> mail header"
  593. " containing '@public.com' anywhere among the addresses."
  594. "<p>Note that leading whitespace is trimmed from the"
  595. " regexp. This can be circumvented in a number of ways, eg"
  596. " by escaping or bracketing it."
  597. "<p> See also the <em>forbidden_posters</em> option for"
  598. " a related mechanism."),
  599. ('anonymous_list', mm_cfg.Radio, ('No', 'Yes'), 0,
  600. 'Hide the sender of a message, replacing it with the list '
  601. 'address (Removes From, Sender and Reply-To fields)'),
  602. ]
  603. config_info['nondigest'] = [
  604. "Policies concerning immediately delivered list traffic.",
  605. ('nondigestable', mm_cfg.Toggle, ('No', 'Yes'), 1,
  606. 'Can subscribers choose to receive mail immediately,'
  607. ' rather than in batched digests?'),
  608. ('msg_header', mm_cfg.Text, (4, 55), 0,
  609. 'Header added to mail sent to regular list members',
  610. "Text prepended to the top of every immediately-delivery"
  611. " message. <p>" + Errors.MESSAGE_DECORATION_NOTE),
  612. ('msg_footer', mm_cfg.Text, (4, 55), 0,
  613. 'Footer added to mail sent to regular list members',
  614. "Text appended to the bottom of every immediately-delivery"
  615. " message. <p>" + Errors.MESSAGE_DECORATION_NOTE),
  616. ]
  617. config_info['bounce'] = Bouncer.GetConfigInfo(self)
  618. return config_info
  619. def Create(self, name, admin, crypted_password):
  620. if name in Utils.list_names():
  621. raise ValueError, 'List %s already exists.' % name
  622. Utils.ValidateEmail(admin)
  623. Utils.MakeDirTree(os.path.join(mm_cfg.LIST_DATA_DIR, name))
  624. self._full_path = os.path.join(mm_cfg.LIST_DATA_DIR, name)
  625. self._internal_name = name
  626. self.Lock()
  627. self.InitVars(name, admin, crypted_password)
  628. self._ready = 1
  629. self.InitTemplates()
  630. self.Save()
  631. self.CreateFiles()
  632. def CreateFiles(self):
  633. # Touch these files so they have the right dir perms no matter what.
  634. # A "just-in-case" thing. This shouldn't have to be here.
  635. ou = os.umask(002)
  636. try:
  637. open(os.path.join(mm_cfg.LOCK_DIR, '%s.lock' %
  638. self._internal_name), 'a+').close()
  639. open(os.path.join(self._full_path, "next-digest"), "a+").close()
  640. open(os.path.join(self._full_path, "next-digest-topics"),
  641. "a+").close()
  642. finally:
  643. os.umask(ou)
  644. def Save(self):
  645. # If more than one client is manipulating the database at once, we're
  646. # pretty hosed. That's a good reason to make this a daemon not a
  647. # program.
  648. self.IsListInitialized()
  649. # copy all public attributes to marshalable dictionary
  650. dict = {}
  651. for key, value in self.__dict__.items():
  652. if key[0] <> '_':
  653. dict[key] = value
  654. # we want to write this dict in a marshal, but be especially paranoid
  655. # about how we write the config.db, so we'll be as robust as possible
  656. # in the face of, e.g. disk full errors. The idea is that we want to
  657. # guarantee that config.db is always valid. The old way had the bad
  658. # habit of writing an incomplete file, which happened to be a valid
  659. # (but bogus) marshal.
  660. fname = os.path.join(self._full_path, 'config.db')
  661. fname_tmp = fname + '.tmp.' + `os.getpid()`
  662. fname_last = fname + ".last"
  663. # Make config.db unreadable by `other', as it contains all the
  664. # list members' passwords (in clear text).
  665. omask = os.umask(007)
  666. try:
  667. try:
  668. fp = open(fname_tmp, 'w')
  669. marshal.dump(dict, fp)
  670. fp.close()
  671. except IOError, status:
  672. os.unlink(fname_tmp)
  673. self.LogMsg('error',
  674. 'Failed config.db file write, retaining old state'
  675. '\n %s' % `status.args`)
  676. Utils.reraise()
  677. # Now do config.db.tmp.xxx -> config.db -> config.db.last
  678. # rotation -- safely.
  679. try:
  680. # might not exist yet
  681. os.unlink(fname_last)
  682. except os.error, (code, msg):
  683. if code <> errno.ENOENT:
  684. Utils.reraise()
  685. try:
  686. # might not exist yet
  687. os.link(fname, fname_last)
  688. except os.error, (code, msg):
  689. if code <> errno.ENOENT:
  690. Utils.reraise()
  691. os.rename(fname_tmp, fname)
  692. finally:
  693. os.umask(omask)
  694. self.CheckHTMLArchiveDir()
  695. self.SaveRequestsDb()
  696. def Load(self, check_version = 1):
  697. if self.__createlock_p:
  698. try:
  699. self.Lock()
  700. except LockFile.AlreadyLockedError:
  701. pass
  702. try:
  703. file = open(os.path.join(self._full_path, 'config.db'), 'r')
  704. except IOError:
  705. raise Errors.MMBadListError, 'Failed to access config info'
  706. try:
  707. dict = marshal.load(file)
  708. if type(dict) <> DictType:
  709. raise Errors.MMBadListError, \
  710. 'Unmarshaled config info is not a dictionary'
  711. except (EOFError, ValueError, TypeError), e:
  712. raise Errors.MMBadListError, ('Failed to unmarshal config info: '
  713. + e)
  714. for key, value in dict.items():
  715. setattr(self, key, value)
  716. file.close()
  717. self._ready = 1
  718. if check_version:
  719. self.CheckValues()
  720. self.CheckVersion(dict)
  721. def LogMsg(self, kind, msg, *args):
  722. """Append a message to the log file for messages of specified kind."""
  723. # For want of a better fallback, we use sys.stderr if we can't get
  724. # a log file. We need a better way to warn of failed log access...
  725. if self._log_files.has_key(kind):
  726. logf = self._log_files[kind]
  727. else:
  728. logf = self._log_files[kind] = StampedLogger(kind)
  729. logf.write(msg % args + '\n')
  730. logf.flush()
  731. def CheckVersion(self, stored_state):
  732. """Migrate prior version's state to new structure, if changed."""
  733. if (self.data_version >= mm_cfg.DATA_FILE_VERSION and
  734. type(self.data_version) == type(mm_cfg.DATA_FILE_VERSION)):
  735. return
  736. else:
  737. self.InitVars() # Init any new variables,
  738. self.Load(check_version = 0) # then reload the file
  739. from versions import Update
  740. Update(self, stored_state)
  741. self.data_version = mm_cfg.DATA_FILE_VERSION
  742. self.Save()
  743. def CheckValues(self):
  744. """Normalize selected values to known formats."""
  745. if self.web_page_url and self.web_page_url[-1] != '/':
  746. self.web_page_url = self.web_page_url + '/'
  747. def IsListInitialized(self):
  748. if not self._ready:
  749. raise Errors.MMListNotReady
  750. def AddMember(self, name, password, digest=0, remote=None):
  751. self.IsListInitialized()
  752. # normalize the name, it could be of the form
  753. #
  754. # <person@place.com> User Name
  755. # person@place.com (User Name)
  756. # etc
  757. #
  758. name = Utils.ParseAddrs(name)
  759. # Remove spaces... it's a common thing for people to add...
  760. name = string.join(string.split(name), '')
  761. # lower case only the domain part
  762. name = Utils.LCDomain(name)
  763. # Validate the e-mail address to some degree.
  764. Utils.ValidateEmail(name)
  765. if self.IsMember(name):
  766. raise Errors.MMAlreadyAMember
  767. if name == string.lower(self.GetListEmail()):
  768. # Trying to subscribe the list to itself!
  769. raise Errors.MMBadEmailError
  770. if digest and not self.digestable:
  771. raise Errors.MMCantDigestError
  772. elif not digest and not self.nondigestable:
  773. raise Errors.MMMustDigestError
  774. if self.subscribe_policy == 0:
  775. # no confirmation or approval necessary:
  776. self.ApprovedAddMember(name, password, digest)
  777. elif self.subscribe_policy == 1 or self.subscribe_policy == 3:
  778. # confirmation:
  779. from Pending import Pending
  780. cookie = Pending().new(name, password, digest)
  781. if remote is not None:
  782. by = " " + remote
  783. remote = " from %s" % remote
  784. else:
  785. by = ""
  786. remote = ""
  787. recipient = self.GetMemberAdminEmail(name)
  788. text = Utils.maketext('verify.txt',
  789. {"email" : name,
  790. "listaddr" : self.GetListEmail(),
  791. "listname" : self.real_name,
  792. "cookie" : cookie,
  793. "hostname" : remote,
  794. "requestaddr": self.GetRequestEmail(),
  795. "remote" : remote,
  796. "listadmin" : self.GetAdminEmail(),
  797. })
  798. msg = Message.UserNotification(
  799. recipient, self.GetRequestEmail(),
  800. '%s -- confirmation of subscription -- request %d' %
  801. (self.real_name, cookie),
  802. text)
  803. msg['Reply-To'] = self.GetRequestEmail()
  804. HandlerAPI.DeliverToUser(self, msg)
  805. if recipient != name:
  806. who = "%s (%s)" % (name, string.split(recipient, '@')[0])
  807. else: who = name
  808. self.LogMsg("subscribe", "%s: pending %s %s",
  809. self._internal_name,
  810. who,
  811. by)
  812. raise Errors.MMSubscribeNeedsConfirmation
  813. else:
  814. # subscription approval is required. add this entry to the admin
  815. # requests database.
  816. self.HoldSubscription(name, password, digest)
  817. raise Errors.MMNeedApproval, \
  818. 'subscriptions to %s require administrator approval' % \
  819. self.real_name
  820. def ProcessConfirmation(self, cookie):
  821. from Pending import Pending
  822. got = Pending().confirmed(cookie)
  823. if not got:
  824. raise Errors.MMBadConfirmation
  825. else:
  826. (email_addr, password, digest) = got
  827. try:
  828. if self.subscribe_policy == 3: # confirm + approve
  829. self.HoldSubscription(email_addr, password, digest)
  830. raise Errors.MMNeedApproval, \
  831. 'subscriptions to %s require administrator approval' % \
  832. self.real_name
  833. self.ApprovedAddMember(email_addr, password, digest)
  834. finally:
  835. self.Save()
  836. def ApprovedAddMember(self, name, password, digest,
  837. ack=None, admin_notif=None):
  838. res = self.ApprovedAddMembers([name], [password],
  839. digest, ack, admin_notif)
  840. # There should be exactly one (key, value) pair in the returned dict,
  841. # extract the possible exception value
  842. res = res.values()[0]
  843. if res is None:
  844. # User was added successfully
  845. return
  846. else:
  847. # Split up the exception list and reraise it here
  848. e, v = res
  849. raise e, v
  850. def ApprovedAddMembers(self, names, passwords, digest,
  851. ack=None, admin_notif=None):
  852. """Subscribe members in list `names'.
  853. Passwords can be supplied in the passwords list. If an empty
  854. password is encountered, a random one is generated and used.
  855. Returns a dict where the keys are addresses that were tried
  856. subscribed, and the corresponding values are either two-element
  857. tuple containing the first exception type and value that was
  858. raised when trying to add that address, or `None' to indicate
  859. that no exception was raised.
  860. """
  861. if ack is None:
  862. if self.send_welcome_msg:
  863. ack = 1
  864. else:
  865. ack = 0
  866. if admin_notif is None:
  867. if self.admin_notify_mchanges:
  868. admin_notif = 1
  869. else:
  870. admin_notif = 0
  871. if type(passwords) is type([]):
  872. pass
  873. else:
  874. # Type error -- ignore the original value
  875. passwords = [None] * len(names)
  876. while len(passwords) < len(names):
  877. passwords.append(None)
  878. result = {}
  879. dirty = 0
  880. for i in range(len(names)):
  881. try:
  882. # normalize the name, it could be of the form
  883. #
  884. # <person@place.com> User Name
  885. # person@place.com (User Name)
  886. # etc
  887. #
  888. name = Utils.ParseAddrs(names[i])
  889. Utils.ValidateEmail(name)
  890. name = Utils.LCDomain(name)
  891. except (Errors.MMBadEmailError, Errors.MMHostileAddress):
  892. # We don't really need the traceback object for the exception,
  893. # and as using it in the wrong way prevents garbage collection
  894. # from working smoothly, we strip it away
  895. result[name] = sys.exc_info()[:2]
  896. # WIBNI we could `continue' within `try' constructs...
  897. if result.has_key(name):
  898. continue
  899. if self.IsMember(name):
  900. result[name] = [Errors.MMAlreadyAMember, name]
  901. continue
  902. self.__AddMember(name, digest)
  903. self.SetUserOption(name, mm_cfg.DisableMime,
  904. 1 - self.mime_is_default_digest,
  905. save_list=0)
  906. # Make sure we set a "good" password
  907. password = passwords[i]
  908. if not password:
  909. password = Utils.MakeRandomPassword()
  910. self.passwords[string.lower(name)] = password
  911. # An address has been added successfully, make sure the
  912. # list config is saved later on
  913. dirty = 1
  914. result[name] = None
  915. if dirty:
  916. self.Save()
  917. if digest:
  918. kind = " (D)"
  919. else:
  920. kind = ""
  921. for name in result.keys():
  922. if result[name] is None:
  923. self.LogMsg("subscribe", "%s: new%s %s",
  924. self._internal_name, kind, name)
  925. if ack:
  926. self.SendSubscribeAck(
  927. name,
  928. self.passwords[string.lower(name)],
  929. digest)
  930. if admin_notif:
  931. adminaddr = self.GetAdminEmail()
  932. subject = ('%s subscription notification' %
  933. self.real_name)
  934. text = Utils.maketext(
  935. "adminsubscribeack.txt",
  936. {"listname" : self.real_name,
  937. "member" : name,
  938. })
  939. msg = Message.OutgoingMessage(text)
  940. msg['From'] = mm_cfg.MAILMAN_OWNER
  941. msg['Subject'] = subject
  942. msg.recips = self.owner
  943. HandlerAPI.DeliverToUser(self, msg)
  944. return result
  945. def DeleteMember(self, name, whence=None, admin_notif=None):
  946. self.IsListInitialized()
  947. # FindMatchingAddresses *should* never return more than 1 address.
  948. # However, should log this, just to make sure.
  949. aliases = Utils.FindMatchingAddresses(name, self.members,
  950. self.digest_members)
  951. if not len(aliases):
  952. raise Errors.MMNoSuchUserError
  953. def DoActualRemoval(alias, me=self):
  954. kind = "(unfound)"
  955. try:
  956. del me.passwords[alias]
  957. except KeyError:
  958. pass
  959. if me.user_options.has_key(alias):
  960. del me.user_options[alias]
  961. try:
  962. del me.members[alias]
  963. kind = "regular"
  964. except KeyError:
  965. pass
  966. try:
  967. del me.digest_members[alias]
  968. kind = "digest"
  969. except KeyError:
  970. pass
  971. map(DoActualRemoval, aliases)
  972. if self.goodbye_msg and len(self.goodbye_msg):
  973. self.SendUnsubscribeAck(name)
  974. self.ClearBounceInfo(name)
  975. self.Save()
  976. if admin_notif is None:
  977. if self.admin_notify_mchanges:
  978. admin_notif = 1
  979. else:
  980. admin_notif = 0
  981. if admin_notif:
  982. subject = '%s unsubscribe notification' % self.real_name
  983. text = Utils.maketext(
  984. 'adminunsubscribeack.txt',
  985. {'member' : name,
  986. 'listname': self.real_name,
  987. })
  988. msg = Message.OutgoingMessage(text)
  989. msg['From'] = mm_cfg.MAILMAN_OWNER
  990. msg['Subject'] = subject
  991. msg.recips = self.owner
  992. HandlerAPI.DeliverToUser(self, msg)
  993. if whence:
  994. whence = "; %s" % whence
  995. else:
  996. whence = ""
  997. self.LogMsg("subscribe", "%s: deleted %s%s",
  998. self._internal_name, name, whence)
  999. def IsMember(self, address):
  1000. return len(Utils.FindMatchingAddresses(address, self.members,
  1001. self.digest_members))
  1002. def HasExplicitDest(self, msg):
  1003. """True if list name or any acceptable_alias is included among the
  1004. to or cc addrs."""
  1005. # Note that qualified host can be different! This allows, eg, for
  1006. # relaying from remote lists that have the same name. Still
  1007. # stringent, but offers a way to provide for remote exploders.
  1008. listname = self.internal_name()
  1009. recips = []
  1010. # First check all dests against simple name:
  1011. for recip in msg.getaddrlist('to') + msg.getaddrlist('cc'):
  1012. curr = string.lower(string.split(recip[1], '@')[0])
  1013. if listname == curr:
  1014. return 1
  1015. recips.append(curr)
  1016. # ... and only then try the regexp acceptable aliases.
  1017. for recip in recips:
  1018. for alias in string.split(self.acceptable_aliases, '\n'):
  1019. stripped = string.strip(alias)
  1020. try:
  1021. # The list alias in `stripped` is a user supplied regexp,
  1022. # which could be malformed.
  1023. if stripped and re.match(recip, stripped):
  1024. return 1
  1025. except re.error:
  1026. # `stripped' is a malformed regexp -- try matching
  1027. # safely, with all non-alphanumerics backslashed:
  1028. if stripped and re.match(recip, re.escape(stripped)):
  1029. return 1
  1030. return 0
  1031. def parse_matching_header_opt(self):
  1032. """Return a list of triples [(field name, regex, line), ...]."""
  1033. # - Blank lines and lines with '#' as first char are skipped.
  1034. # - Leading whitespace in the matchexp is trimmed - you can defeat
  1035. # that by, eg, containing it in gratuitous square brackets.
  1036. all = []
  1037. for line in string.split(self.bounce_matching_headers, '\n'):
  1038. stripped = string.strip(line)
  1039. if not stripped or (stripped[0] == "#"):
  1040. # Skip blank lines and lines *starting* with a '#'.
  1041. continue
  1042. else:
  1043. try:
  1044. h, e = re.split(":[ \t]*", stripped, 1)
  1045. try:
  1046. re.compile(e)
  1047. all.append((h, e, stripped))
  1048. except re.error, cause:
  1049. # The regexp in this line is malformed -- log it
  1050. # and ignore it
  1051. self.LogMsg("config", "%s - "
  1052. "bad regexp %s [%s] "
  1053. "in bounce_matching_header line %s"
  1054. % (self.real_name, `e`,
  1055. `cause`, `stripped`))
  1056. except ValueError:
  1057. # Whoops - some bad data got by:
  1058. self.LogMsg("config", "%s - "
  1059. "bad bounce_matching_header line %s"
  1060. % (self.real_name, `stripped`))
  1061. return all
  1062. def HasMatchingHeader(self, msg):
  1063. """True if named header field (case-insensitive) matches regexp.
  1064. Case insensitive.
  1065. Returns constraint line which matches or empty string for no
  1066. matches."""
  1067. pairs = self.parse_matching_header_opt()
  1068. for field, matchexp, line in pairs:
  1069. fragments = msg.getallmatchingheaders(field)
  1070. subjs = []
  1071. l = len(field)
  1072. for f in fragments:
  1073. # Consolidate header lines, stripping header name & whitespace.
  1074. if (len(f) > l
  1075. and f[l] == ":"
  1076. and string.lower(field) == string.lower(f[0:l])):
  1077. # Non-continuation line - trim header name:
  1078. subjs.append(f[l+2:])
  1079. elif not subjs:
  1080. # Whoops - non-continuation that matches?
  1081. subjs.append(f)
  1082. else:
  1083. # Continuation line.
  1084. subjs[-1] = subjs[-1] + f
  1085. for s in subjs:
  1086. # This is safe because parse_matching_header_opt only
  1087. # returns valid regexps
  1088. if re.search(matchexp, s, re.I):
  1089. return line
  1090. return 0
  1091. # msg should be an Message.Message object.
  1092. def Post(self, msg):
  1093. self.IsListInitialized()
  1094. # TBD: this is bogus and will later be configurable
  1095. import Mailman.Handlers.HandlerAPI
  1096. Mailman.Handlers.HandlerAPI.DeliverToList(self, msg)
  1097. self.Save()
  1098. def Locked(self):
  1099. return self.__lock.locked()
  1100. def Lock(self):
  1101. self.__lock.lock()
  1102. def Unlock(self):
  1103. try:
  1104. self.__lock.unlock()
  1105. except LockFile.NotLockedError:
  1106. pass
  1107. def __repr__(self):
  1108. if self.Locked():
  1109. status = " (locked)"
  1110. else:
  1111. status = ""
  1112. return ("<%s.%s %s%s at %s>" %
  1113. (self.__module__, self.__class__.__name__,
  1114. `self._internal_name`, status, hex(id(self))[2:]))
  1115. def internal_name(self):
  1116. return self._internal_name
  1117. def fullpath(self):
  1118. return self._full_path