Patch
James Vasile
james at hackervisions.org
Fri Aug 21 06:25:18 EST 2009
One of the neat things about Planet is that it passes channel settings
in the config.ini through to the template. This makes the face
settings possible without any reference to faces in the code. It's
cool.
For some reason, we don't do that with planet-level settings. I have
some custom fields in config.ini that I want the template to see, so I
adjusted tmpl.py to pass config.planet_options() to the template.
Patch is below. Released uner GPL and Python license.
Regards,
James Vasile
=== modified file 'planet/shell/tmpl.py'
--- planet/shell/tmpl.py 2009-01-09 08:11:16 +0000
+++ planet/shell/tmpl.py 2009-08-20 20:15:44 +0000
@@ -182,6 +182,16 @@
context.sources.append(context.source)
del context['source']
+def merge_dict(a, b):
+ """Return a hash containing all the keys and vals of a and all
+ those of b that don't clash with a. Modifies a in place and also
+ returns a."""
+
+ for key in b.keys():
+ if not a.has_key(key):
+ a[key] = b[key]
+ return a
+
def template_info(source):
""" get template information from a feedparser output """
@@ -214,11 +224,8 @@
item['guid_isPermaLink']='false'
# feed level information
+ merge_dict(output, config.planet_options())
output['generator'] = config.generator_uri()
- output['name'] = config.name()
- output['link'] = config.link()
- output['owner_name'] = config.owner_name()
- output['owner_email'] = config.owner_email()
if config.feed():
output['feed'] = config.feed()
output['feedtype'] = config.feed().find('rss')>=0 and 'rss' or 'atom'
More information about the devel
mailing list