changeset 1615:9fa2ec252d1f

mailimport: add envelope feature for target page spec
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 09 Oct 2006 18:12:13 +0200
parents f89eb93324e2
children d1c37c39f8ad
files MoinMoin/config/multiconfig.py MoinMoin/mail/mailimport.py
diffstat 2 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/config/multiconfig.py	Mon Oct 09 17:41:13 2006 +0200
+++ b/MoinMoin/config/multiconfig.py	Mon Oct 09 18:12:13 2006 +0200
@@ -310,6 +310,7 @@
     mail_from = None # u'Juergen Wiki <noreply@jhwiki.org>'
 
     mail_import_subpage_template = u"$from-$date-$subject" # used for mail import
+    mail_import_pagename_envelope = u"%s" # use u"+ %s/" to add "+ " and "/" automatically
     mail_import_wiki_address = None # the e-mail address for e-mails that should go into the wiki
     mail_import_secret = ""
 
--- a/MoinMoin/mail/mailimport.py	Mon Oct 09 17:41:13 2006 +0200
+++ b/MoinMoin/mail/mailimport.py	Mon Oct 09 18:12:13 2006 +0200
@@ -123,7 +123,7 @@
             'from_addr': from_addr,
             'subject': subject, 'date': date}
 
-def get_pagename_content(request, msg, email_subpage_template, wiki_address):
+def get_pagename_content(request, msg, email_pagename_envelope, email_subpage_template, wiki_address):
     """ Generates pagename and content according to the specification
         that can be found on MoinMoin:FeatureRequests/WikiEmailintegration """
     generate_summary = False
@@ -152,13 +152,18 @@
         msg['subject'] = '(...)' # we need non-empty subject
 
     pagename_tpl = pagename_tpl.strip()
-    if pagename_tpl.endswith("/"):
-        pagename_tpl += email_subpage_template
-
     # last resort
     if not pagename_tpl:
         pagename_tpl = email_subpage_template
 
+    # for normal use, email_pagename_envelope is just u"%s" - so nothing changes.
+    # for special use, you can use u"+ %s/" - so you don't need to enter "+"
+    # and "/" in every email, but you get the result as if you did.
+    pagename_tpl = email_pagename_envelope % pagename_tpl
+
+    if pagename_tpl.endswith("/"):
+        pagename_tpl += email_subpage_template
+
     # rewrite using string.formatter when python 2.4 is mandatory
     pagename = (pagename_tpl.replace("$from", msg['from_addr'][0]).
                 replace("$date", msg['date']).
@@ -195,6 +200,7 @@
     msg = process_message(message)
 
     email_subpage_template = request.cfg.mail_import_subpage_template
+    email_pagename_envelope = request.cfg.mail_import_pagename_envelope
     wiki_address = request.cfg.mail_import_wiki_address or request.cfg.mail_from
 
     request.user = user.get_by_email_address(request, msg['from_addr'][1])
@@ -202,7 +208,7 @@
     if not request.user:
         raise ProcessingError("No suitable user found for mail address %r" % (msg['from_addr'][1], ))
 
-    d = get_pagename_content(request, msg, email_subpage_template, wiki_address)
+    d = get_pagename_content(request, msg, email_pagename_envelope, email_subpage_template, wiki_address)
     pagename = d['pagename']
     generate_summary = d['generate_summary']