feed: Pass config and section arguments to get_message()
authorW. Trevor King <wking@tremily.us>
Wed, 23 Jan 2013 22:51:50 +0000 (17:51 -0500)
committerW. Trevor King <wking@tremily.us>
Wed, 23 Jan 2013 22:51:50 +0000 (17:51 -0500)
Otherwise it will always use the default config.

Also add section fallback code to get_message in case the
feed-specific section is not in the config file.  This is useful for
testing, although in production every feed should have a section to
hold it's URL.

Signed-off-by: W. Trevor King <wking@tremily.us>
rss2email/email.py
rss2email/feed.py

index b8ccdd446c1af54a3c9b008d5a9fe16568e1000f..6f333793e3b977c31d13ab060c00e6bae30a7f44 100644 (file)
@@ -86,6 +86,8 @@ def get_message(sender, recipient, subject, body, content_type,
     """
     if config is None:
         config = _config.CONFIG
+    if section not in config.sections():
+        section = 'DEFAULT'
     encodings = [
         x.strip() for x in config.get(section, 'encodings').split(',')]
 
index 9a1c70974b0dfdf9cbaff647d8ac69de1fdf56cb..3621a0b94b17823b2446d7a11a20a32fec33fe6a 100644 (file)
@@ -438,7 +438,9 @@ class Feed (object):
             subject=subject,
             body=content['value'],
             content_type=content['type'].split('/', 1)[1],
-            extra_headers=extra_headers)
+            extra_headers=extra_headers,
+            config=self.config,
+            section=self.section)
         return (guid, id_, sender, message)
 
     def _get_entry_id(self, entry):