Commits

Dan Carroll committed e5ecaf0

Move all settings to an ACTIVITSYNC_SETTINGS dictionary

Comments (0)

Files changed (7)

 * BACKWARDS INCOMPATIBLE CHANGE: Renamed TwitterProvider to TwitterUserProvider
   to distinguish it from the new TwitterSearchProvider
 
+* BACKWARDS INCOMPATIBLE CHANGE: Moved all provider settings into a
+  ACTIVITYSYNC_SETTINGS dictionary to cut down on clutter
+
 
 Version 0.1.2, 8 Feb 2011
 -------------------------
 
 - Twitter support depends on python-twitter_
 
-- Google Reader and Reddit support depend on feedparser_
+- Google Reader and Reddit support depend on feedparser_ (version 4.1)
 
 
 Installation
     )
 
 - Add provider settings to settings.py (dependent on which providers are added).
-  Settings required for built-in providers are::
-
-    TWITTER_USERNAME        = '' # Username to use for TwitterUserProvider
-    TWITTER_SEARCHTERM      = '' # Search term to use for TwitterSearchProvider
-    REDDIT_USERNAME         = '' # Username to use for RedditProvider
-    GOOGLEREADER_SHARED_RSS = '' # URL of your shared items RSS
-    GOOGLEREADER_PUBLIC_URL = '' # URL to public page
+  For ease of use and organizational purposes, all settings for providers should
+  be stored in the ``ACTIVITYSYNC_SETTINGS`` dictionary. Settings required for
+  built-in providers are::
+    
+    ACTIVITYSYNC_SETTINGS = {
+        'TWITTER_USERNAME': '', # Username to use for TwitterUserProvider
+        'TWITTER_SEARCHTERM': '', # Search term to use for TwitterSearchProvider
+        'REDDIT_USERNAME': '', # Username to use for RedditProvider
+        'GOOGLEREADER_SHARED_RSS': '', # URL of Google Reader shared items RSS feed
+        'GOOGLEREADER_PUBLIC_URL': '', # URL to Google Reader public page
+    }
 
 - Sync database to create needed models::
 

activitysync/providers/googlereader.py

         item_list = []
 
         print 'Attempting to parse Google Reader feed'
-        parsed_feed = feedparser.parse(settings.GOOGLEREADER_SHARED_RSS)
+        feed_url = settings.ACTIVITYSYNC_SETTINGS['GOOGLEREADER_SHARED_RSS']
+        parsed_feed = feedparser.parse(feed_url)
     
         for entry in parsed_feed.entries:
             title = entry.title.encode(parsed_feed.encoding, "xmlcharrefreplace")
         return 'Shared'
 
     def link(self):
-        return settings.GOOGLEREADER_PUBLIC_URL
+        return settings.ACTIVITYSYNC_SETTINGS['GOOGLEREADER_PUBLIC_URL']
 
     def sourceid(self):
         return 'googlereader'

activitysync/providers/redditprovider.py

         item_list = []
 
         print 'Attempting to parse Reddit feed'
-        username = settings.REDDIT_USERNAME
+        username = settings.ACTIVITYSYNC_SETTINGS['REDDIT_USERNAME']
         parsed_feed = feedparser.parse("http://www.reddit.com/user/%s/liked/.rss" % username)
 
         for entry in parsed_feed.entries:
         return 'Liked'
 
     def link(self):
-        return 'http://www.reddit.com/user/%s/' % settings.REDDIT_USERNAME
+        return ('http://www.reddit.com/user/%s/' %
+            settings.ACTIVITYSYNC_SETTINGS['REDDIT_USERNAME'])
 
     def sourceid(self):
         return 'reddit'

activitysync/providers/twitterprovider.py

 
         print 'Attempting to obtain Twitter items'
         api = TwitterLibrary.Api()
-        username = settings.TWITTER_USERNAME
+        username = settings.ACTIVITYSYNC_SETTINGS['TWITTER_USERNAME']
         print ' Username: %s' % username
         statuses = api.GetUserTimeline(username, count=50)
 
         return ''
 
     def link(self):
-        return 'http://twitter.com/%s' % settings.TWITTER_USERNAME
+        return ('http://twitter.com/%s' %
+            settings.ACTIVITYSYNC_SETTINGS['TWITTER_USERNAME'])
 
     def sourceid(self):
         return 'twitter'
 
         print 'Attempting to obtain Twitter items'
         api = TwitterLibrary.Api()
-        query = settings.TWITTER_SEARCHTERM
+        query = settings.ACTIVITYSYNC_SETTINGS['TWITTER_SEARCHTERM']
         print ' Search term: %s' % query
         statuses = api.GetSearch(term=query, per_page=50)
 
         return ''
 
     def link(self):
-        return 'http://twitter.com/search?q=%s' % settings.TWITTER_SEARCHTERM
+        return ('http://twitter.com/search?q=%s' %
+            settings.ACTIVITYSYNC_SETTINGS['TWITTER_SEARCHTERM'])
 
     def sourceid(self):
         return 'twitter'

examples/activitydisplay/requirements.txt

 Django==1.2.4
+feedparser==4.1
 httplib2==0.6.0
 oauth2==1.5.163
 python-twitter==0.8.1

examples/activitydisplay/settings.py

     # 'activitysync.providers.redditprovider.RedditProvider',
 )
 
-TWITTER_USERNAME = 'twitter'
-TWITTER_SEARCHTERM = 'django'
-# REDDIT_USERNAME = ''
-# GOOGLEREADER_SHARED_RSS = ''
-# GOOGLEREADER_PUBLIC_URL = ''
+ACTIVITYSYNC_SETTINGS = {
+    'TWITTER_USERNAME': 'twitter',
+    'TWITTER_SEARCHTERM': 'django',
+    # 'REDDIT_USERNAME': '',
+    # 'GOOGLEREADER_SHARED_RSS': '',
+    # 'GOOGLEREADER_PUBLIC_URL': '',
+}