~rnix/mailman/anon-subscribe

« back to all changes in this revision

Viewing changes to src/mailman/archiving/mhonarc.py

  • Committer: Robert Niederreiter
  • Date: 2012-12-10 10:04:59 UTC
  • mfrom: (7155.2.29 3.0)
  • Revision ID: rnix@squarewave.at-20121210100459-hr0sz28hymmljaa3
merge main 3.0 changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
from zope.interface import implementer
33
33
 
34
34
from mailman.config import config
 
35
from mailman.config.config import external_configuration
35
36
from mailman.interfaces.archiver import IArchiver
36
37
from mailman.utilities.string import expand
37
38
 
46
47
 
47
48
    name = 'mhonarc'
48
49
 
49
 
    @staticmethod
50
 
    def list_url(mlist):
 
50
    def __init__(self):
 
51
        # Read our specific configuration file
 
52
        archiver_config = external_configuration(
 
53
            config.archiver.mhonarc.configuration)
 
54
        self.base_url = archiver_config.get('general', 'base_url')
 
55
        self.command = archiver_config.get('general', 'command')
 
56
 
 
57
    def list_url(self, mlist):
51
58
        """See `IArchiver`."""
52
59
        # XXX What about private MHonArc archives?
53
 
        return expand(config.archiver.mhonarc.base_url,
 
60
        return expand(self.base_url,
54
61
                      dict(listname=mlist.fqdn_listname,
55
62
                           hostname=mlist.domain.url_host,
56
63
                           fqdn_listname=mlist.fqdn_listname,
57
64
                           ))
58
65
 
59
 
    @staticmethod
60
 
    def permalink(mlist, msg):
 
66
    def permalink(self, mlist, msg):
61
67
        """See `IArchiver`."""
62
68
        # XXX What about private MHonArc archives?
63
69
        # It is the LMTP server's responsibility to ensure that the message
66
72
        message_id_hash = msg.get('x-message-id-hash')
67
73
        if message_id_hash is None:
68
74
            return None
69
 
        return urljoin(MHonArc.list_url(mlist), message_id_hash)
 
75
        return urljoin(self.list_url(mlist), message_id_hash)
70
76
 
71
 
    @staticmethod
72
 
    def archive_message(mlist, msg):
 
77
    def archive_message(self, mlist, msg):
73
78
        """See `IArchiver`."""
74
79
        substitutions = config.__dict__.copy()
75
80
        substitutions['listname'] = mlist.fqdn_listname
76
 
        command = expand(config.archiver.mhonarc.command, substitutions)
 
81
        command = expand(self.command, substitutions)
77
82
        proc = subprocess.Popen(
78
83
            command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
79
84
            shell=True)