#NEWLINE# def home( request ) : #NEWLINE# #INDENT# 'Render a users home feed.\n\n    Authentication is required.\n    ' #NEWLINE# if ( not request . session . get ( 'nickname' , None ) ) : #NEWLINE# #INDENT# return HttpResponseRedirect ( reverse ( 'login' ) ) #NEWLINE# #UNINDENT# f = friendfeed . FriendFeed ( request . session [ 'nickname' ] , request . session [ 'key' ] ) #NEWLINE# start = max ( get_integer_argument ( kwargs , 'start' , 0 ) , 0 ) #NEWLINE# num = get_integer_argument ( request , 'num' , NUM ) #NEWLINE# data = f . fetch_home_feed ( ** request_to_feed_args_dict ( request ) ) #NEWLINE# if ( 'errorCode' in data ) : #NEWLINE# #INDENT# return error ( request , data ) #NEWLINE# #UNINDENT# entries = [ entry for entry in data [ 'entries' ] if ( not entry [ 'hidden' ] ) ] #NEWLINE# hidden = [ entry for entry in data [ 'entries' ] if entry [ 'hidden' ] ] #NEWLINE# new_start = start #NEWLINE# while ( ( len ( entries ) < num ) and ( ( ( new_start - start ) / num ) < 3 ) ) : #NEWLINE# #INDENT# new_start = ( new_start + num ) #NEWLINE# kwargs = request_to_feed_args_dict ( request ) #NEWLINE# kwargs [ 'start' ] = new_start #NEWLINE# data = f . fetch_home_feed ( ** kwargs ) #NEWLINE# if ( 'errorCode' in data ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# more_entries = [ entry for entry in data [ 'entries' ] if ( not entry [ 'hidden' ] ) ] #NEWLINE# more_hidden = [ entry for entry in data [ 'entries' ] if entry [ 'hidden' ] ] #NEWLINE# entries . extend ( more_entries ) #NEWLINE# hidden . extend ( more_hidden ) #NEWLINE# #UNINDENT# entries = entries [ : num ] #NEWLINE# extra_context = { #NEWLINE# #INDENT# 'entries' : entries , #NEWLINE# 'next' : ( ( start + len ( entries ) ) + len ( hidden ) ) , #NEWLINE# 'hidden' : hidden , #NEWLINE# #UNINDENT# } #NEWLINE# if ( start > 0 ) : #NEWLINE# #INDENT# extra_context [ 'has_previous' ] = True #NEWLINE# extra_context [ 'previous' ] = max ( ( start - num ) , 0 ) #NEWLINE# #UNINDENT# if ( request . GET . get ( 'output' , 'html' ) == 'atom' ) : #NEWLINE# #INDENT# return atom ( entries ) #NEWLINE# #UNINDENT# return render_to_response ( 'home.html' , extra_context , context_instance = RequestContext ( request ) )