Store fields config value as python dict

This commit is contained in:
Martin Burchell 2016-09-20 17:39:14 +01:00
parent a46cc5299c
commit 52df40e58b
1 changed files with 4 additions and 3 deletions

View File

@ -1,3 +1,4 @@
import ast
import logging
import urllib
import commands
@ -66,8 +67,8 @@ class GoogleAnalyticsPlugin(p.SingletonPlugin):
self.googleanalytics_id = config['googleanalytics.id']
self.googleanalytics_domain = config.get(
'googleanalytics.domain', 'auto')
self.googleanalytics_fields = config.get(
'googleanalytics.fields', '{}')
self.googleanalytics_fields = ast.literal_eval(config.get(
'googleanalytics.fields', '{}'))
self.googleanalytics_javascript_url = h.url_for_static(
'/scripts/ckanext-googleanalytics.js')
@ -273,6 +274,6 @@ class GoogleAnalyticsPlugin(p.SingletonPlugin):
'''
data = {'googleanalytics_id': self.googleanalytics_id,
'googleanalytics_domain': self.googleanalytics_domain,
'googleanalytics_fields': self.googleanalytics_fields}
'googleanalytics_fields': str(self.googleanalytics_fields)}
return p.toolkit.render_snippet(
'googleanalytics/snippets/googleanalytics_header.html', data)