#NEWLINE# def tablefy( objects , views = True ) : #NEWLINE# #INDENT# '\n    Given a list of objects, build a matrix that is can be printed as a table.\n    Also return the headers for that table. Populate the given url with the pk\n    of the object. Return all headers, field array, and urls in a seperate\n    lists.\n\n    :param  objects: A list of objects to make the matrix out of.\n    :type   objects: AddressRecords\n    ' #NEWLINE# matrix = [ ] #NEWLINE# urls = [ ] #NEWLINE# headers = [ ] #NEWLINE# if ( not objects ) : #NEWLINE# #INDENT# return ( None , None , None ) #NEWLINE# #UNINDENT# for ( title , value ) in objects [ 0 ] . details ( ) : #NEWLINE# #INDENT# headers . append ( title ) #NEWLINE# #UNINDENT# if views : #NEWLINE# #INDENT# headers . append ( 'Views' ) #NEWLINE# #UNINDENT# for obj in objects : #NEWLINE# #INDENT# row = [ ] #NEWLINE# urls . append ( obj . get_absolute_url ( ) ) #NEWLINE# for ( title , value ) in obj . details ( ) : #NEWLINE# #INDENT# row . append ( value ) #NEWLINE# #UNINDENT# if views : #NEWLINE# #INDENT# views = '' #NEWLINE# if hasattr ( urls , 'views' ) : #NEWLINE# #INDENT# for view in obj . views . all ( ) : #NEWLINE# #INDENT# views += ( view . name + ', ' ) #NEWLINE# #UNINDENT# views = views . strip ( ', ' ) #NEWLINE# row . append ( views ) #NEWLINE# #UNINDENT# #UNINDENT# matrix . append ( row ) #NEWLINE# #UNINDENT# return ( headers , matrix , urls )