Permalink
Browse files

Line width OCD

  • Loading branch information...
1 parent efb8720 commit 90d056901c1f837a02699bca0c9ba893d8b5a552 @ericflo ericflo committed Sep 22, 2010
Showing with 25 additions and 14 deletions.
  1. +13 −9 cass.py
  2. +2 −2 tweets/views.py
  3. +10 −3 users/views.py
View
22 cass.py
@@ -68,19 +68,20 @@ def _get_line(cf, username, start, limit):
"""
# First we need to get the raw timeline (in the form of tweet ids)
- # We get one more tweet than asked for, and if we exceed the limit by doing so,
- # that tweet's key (timestamp) is returned as the 'next' key for pagination.
+ # We get one more tweet than asked for, and if we exceed the limit by doing
+ # so, that tweet's key (timestamp) is returned as the 'next' key for
+ # pagination.
start = long(start) if start else ''
next = None
try:
- timeline = cf.get(str(username), column_start=start, column_count=limit + 1,
- column_reversed=True)
+ timeline = cf.get(str(username), column_start=start,
+ column_count=limit + 1, column_reversed=True)
except NotFoundException:
return [], next
if len(timeline) > limit:
- # Find the minimum timestamp from our get (the oldest one), and convert it
- # to a non-floating value.
+ # Find the minimum timestamp from our get (the oldest one), and convert
+ # it to a non-floating value.
oldest_timestamp = min(timeline.keys())
# Present the string version of the oldest_timestamp for the UI...
@@ -90,10 +91,12 @@ def _get_line(cf, username, start, limit):
# if from timeline.
del timeline[oldest_timestamp]
- # Now we do a multiget to get the tweets themselves, comes back in random order
+ # Now we do a multiget to get the tweets themselves, which comes back in
+ # random order
unordered_tweets = TWEET.multiget(timeline.values())
# Order the tweets in the order we got back from the timeline
- ordered_tweets = [unordered_tweets.get(tweet_id) for tweet_id in timeline.values()]
+ ordered_tweets = [unordered_tweets.get(tweet_id)
+ for tweet_id in timeline.values()]
# We want to get the information about the user who made the tweet
# First, pull out the list of unique users for our tweets
@@ -119,7 +122,8 @@ def get_user_by_username(username):
def get_friend_usernames(username, count=5000):
"""
- Given a username, gets the usernames of the people that the user is following.
+ Given a username, gets the usernames of the people that the user is
+ following.
"""
return _get_friend_or_follower_usernames(FRIENDS, username, count)
View
4 tweets/views.py
@@ -22,8 +22,8 @@ def timeline(request):
return HttpResponseRedirect(reverse('timeline'))
start = request.GET.get('start')
if request.user['is_authenticated']:
- tweets,next = cass.get_timeline(request.session['username'], start=start,
- limit=NUM_PER_PAGE)
+ tweets,next = cass.get_timeline(request.session['username'],
+ start=start, limit=NUM_PER_PAGE)
else:
tweets,next = cass.get_userline(cass.PUBLIC_USERLINE_KEY, start=start,
limit=NUM_PER_PAGE)
View
13 users/views.py
@@ -43,7 +43,8 @@ def logout(request):
def find_friends(request):
friend_usernames = []
if request.user['is_authenticated']:
- friend_usernames = cass.get_friend_usernames(request.session['username']) + [request.session['username']]
+ friend_usernames = cass.get_friend_usernames(
+ request.session['username']) + [request.session['username']]
q = request.GET.get('q')
result = None
searched = False
@@ -69,10 +70,16 @@ def modify_friend(request):
removed = False
if request.user['is_authenticated']:
if 'add-friend' in request.POST:
- cass.add_friends(request.session['username'], [request.POST['add-friend']])
+ cass.add_friends(
+ request.session['username'],
+ [request.POST['add-friend']]
+ )
added = True
if 'remove-friend' in request.POST:
- cass.remove_friends(request.session['username'], [request.POST['remove-friend']])
+ cass.remove_friends(
+ request.session['username'],
+ [request.POST['remove-friend']]
+ )
removed = True
if next:
return HttpResponseRedirect(next)

0 comments on commit 90d0569

Please sign in to comment.