Fixing up setup.py and making sure routes exist for site and publisher reports
Fixing up setup.py and making sure routes exist for site and publisher reports

import logging import logging
from ckan.lib.base import BaseController, c, render from ckan.lib.base import BaseController, c, render
import report_model import report_model
   
log = logging.getLogger('ckanext.ga-report') log = logging.getLogger('ckanext.ga-report')
   
class GaReport(BaseController): class GaReport(BaseController):
def index(self): def index(self):
return render('index.html') return render('ga_report/site/index.html')
   
   
  class GaPublisherReport(BaseController):
   
  def index(self, id):
  return render('ga_report/publisher/index.html')
   
import logging import logging
import ckan.lib.helpers as h import ckan.lib.helpers as h
  import ckan.plugins as p
from ckan.plugins import implements, toolkit from ckan.plugins import implements, toolkit
import gasnippet #import gasnippet
import commands #import commands
import dbutil #import dbutil
   
log = logging.getLogger('ckanext.ga-report') log = logging.getLogger('ckanext.ga-report')
   
class GoogleAnalyticsPlugin(p.SingletonPlugin): class GAReportPlugin(p.SingletonPlugin):
implements(p.IConfigurer, inherit=True) implements(p.IConfigurer, inherit=True)
implements(p.IRoutes, inherit=True) implements(p.IRoutes, inherit=True)
   
def update_config(self, config): def update_config(self, config):
toolkit.add_template_directory(config, 'templates') toolkit.add_template_directory(config, 'templates')
toolkit.add_public_directory(config, 'public') toolkit.add_public_directory(config, 'public')
   
def after_map(self, map): def after_map(self, map):
map.connect( map.connect(
'/data/analytics/index', '/data/analytics/usage',
controller='ckanext.ga-report.controller:GaReport', controller='ckanext.ga_report.controller:GaReport',
  action='index'
  )
  map.connect(
  '/data/analytics/publisher/{id}',
  controller='ckanext.ga_report.controller:GaPublisherReport',
action='index' action='index'
) )
return map return map
   
   
file:a/setup.py -> file:b/setup.py
from setuptools import setup, find_packages from setuptools import setup, find_packages
import sys, os import sys, os
   
version = '0.1' version = '0.1'
   
setup( setup(
name='ckanext-ga-report', name='ckanext-ga-report',
version=version, version=version,
description="GA reporting for CKAN", description="GA reporting for CKAN",
long_description="""\ long_description="""\
""", """,
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='', keywords='',
author='David Read', author='David Read',
author_email='david.read@hackneyworkshop.com', author_email='david.read@hackneyworkshop.com',
url='', url='',
license='', license='',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
namespace_packages=['ckanext', 'ckanext.ga_report'], namespace_packages=['ckanext', 'ckanext.ga_report'],
include_package_data=True, include_package_data=True,
zip_safe=False, zip_safe=False,
install_requires=[ install_requires=[
'gdata', 'gdata',
'google-api-python-client' 'google-api-python-client'
], ],
entry_points=\ entry_points=\
""" """
[ckan.plugins] [ckan.plugins]
# Add plugins here, eg # Add plugins here, eg
ga-report=ckanext.ga_report.plugin:GaReportPlugin ga-report=ckanext.ga_report.plugin:GAReportPlugin
   
[paste.paster_command] [paste.paster_command]
loadanalytics = ckanext.ga_report.command:LoadAnalytics loadanalytics = ckanext.ga_report.command:LoadAnalytics
initdb = ckanext.ga_report.command:InitDB initdb = ckanext.ga_report.command:InitDB
""", """,
) )