<s> from django_tables . base import BaseTable , Rows , TableOptions <EOL> __all__ = ( '<STR_LIT>' , ) <EOL> class SQLTableOptions ( TableOptions ) : <EOL> def __init__ ( self , options = None ) : <EOL> super ( SQLTableOptions , self ) . __init__ ( options ) <EOL> self . columns = getattr ( options , '<STR_LIT>' , None ) <EOL> self . exclude = getattr ( options , '<STR_LIT>' , None ) <EOL> class SQLRows ( Rows ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( SQLRows , self ) . __init__ ( * args , ** kwargs ) <EOL> def _reset ( self ) : <EOL> self . _length = None <EOL> def __len__ ( self ) : <EOL> """<STR_LIT>""" <EOL> if getattr ( self , '<STR_LIT>' , None ) is None : <EOL> self . _length = self . table . data . count ( ) <EOL> return self . _length <EOL> count = __len__ <EOL> class SQLTable ( BaseTable ) : <EOL> rows_class = SQLRows <EOL> def __init__ ( self , data = None , * args , ** kwargs ) : <EOL> if data is None : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> else : <EOL> self . queryset = data <EOL> super ( SQLTable , self ) . __init__ ( self . queryset , * args , ** kwargs ) <EOL> def _validate_column_name ( self , name , purpose ) : <EOL> return True <EOL> def _build_snapshot ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _columns . _reset ( ) <EOL> self . _rows . _reset ( ) <EOL> qs = self . queryset <EOL> if self . order_by : <EOL> actual_order_by = self . _resolve_sort_directions ( self . order_by ) <EOL> qs = qs . order_by ( * self . _cols_to_fields ( actual_order_by ) ) <EOL> return qs </s>
