~andrea-crotti-0/mailman/readthedocs

« back to all changes in this revision

Viewing changes to src/mailman/mta/docs/decorating.rst

  • Committer: Barry Warsaw
  • Date: 2012-03-04 23:39:08 UTC
  • Revision ID: barry@list.org-20120304233908-upzd5p38b8rbh3gl
Template indirection now also in effect for regular and digest headers and
footers, using the same semantics and algorithm as for welcome and goodbye
messages.

Additional schema changes:

   - msg_header       -> header_uri
   - msg_footer       -> footer_uri
   - digest_header    -> digest_header_uri
   - digest_footer    -> digest_footer_uri

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
Decorations are added when the mailing list had a header and/or footer
23
23
defined, and the decoration handler is told to do personalized decorations.
 
24
We start by writing the site-global header and footer template.
24
25
::
25
26
 
26
 
    >>> mlist = create_list('test@example.com')
27
 
    >>> mlist.msg_header = """\
 
27
    >>> import os, tempfile
 
28
    >>> template_dir = tempfile.mkdtemp()
 
29
    >>> site_dir = os.path.join(template_dir, 'site', 'en')
 
30
    >>> os.makedirs(site_dir)
 
31
    >>> config.push('templates', """
 
32
    ... [paths.testing]
 
33
    ... template_dir: {0}
 
34
    ... """.format(template_dir))
 
35
 
 
36
    >>> myheader_path = os.path.join(site_dir, 'myheader.txt')
 
37
    >>> with open(myheader_path, 'w') as fp:
 
38
    ...     print >> fp, """\
28
39
    ... Delivery address: $user_address
29
40
    ... Subscribed address: $user_delivered_to
30
41
    ... """
31
 
 
32
 
    >>> mlist.msg_footer = """\
 
42
    >>> myfooter_path = os.path.join(site_dir, 'myfooter.txt')
 
43
    >>> with open(myfooter_path, 'w') as fp:
 
44
    ...     print >> fp, """\
33
45
    ... User name: $user_name
34
46
    ... Password: $user_password
35
47
    ... Language: $user_language
36
48
    ... Options: $user_optionsurl
37
49
    ... """
 
50
 
 
51
Then create a mailing list which will use this header and footer.  Because
 
52
these are site-global templates, we can use a shorted URL.
 
53
 
 
54
    >>> mlist = create_list('test@example.com')
 
55
    >>> mlist.header_uri = 'mailman:///myheader.txt'
 
56
    >>> mlist.footer_uri = 'mailman:///myfooter.txt'
38
57
    
39
58
    >>> transaction.commit()
40
59
 
201
220
    <BLANKLINE>
202
221
    This is a test.
203
222
    ----------
 
223
 
 
224
.. Clean up
 
225
 
 
226
    >>> config.pop('templates')
 
227
    >>> import shutil
 
228
    >>> shutil.rmtree(template_dir)