<s> """<STR_LIT>""" <EOL> from inspect import getargspec <EOL> from warnings import warn <EOL> def call_with_connection ( func ) : <EOL> arg_names , varargs , varkwargs , defaults = getargspec ( func ) <EOL> updated = ( '<STR_LIT>' in arg_names or varkwargs ) <EOL> if not updated : <EOL> warn ( "<STR_LIT>" <EOL> "<STR_LIT>" % func . __name__ , <EOL> DeprecationWarning , stacklevel = <NUM_LIT:3> ) <EOL> def inner ( * args , ** kwargs ) : <EOL> if '<STR_LIT>' not in kwargs : <EOL> from django . db import connection <EOL> kwargs [ '<STR_LIT>' ] = connection <EOL> warn ( "<STR_LIT>" % <EOL> func . __name__ , DeprecationWarning , <EOL> stacklevel = <NUM_LIT:2> ) <EOL> if updated : <EOL> return func ( * args , ** kwargs ) <EOL> if '<STR_LIT>' in kwargs : <EOL> del kwargs [ '<STR_LIT>' ] <EOL> return func ( * args , ** kwargs ) <EOL> return inner <EOL> def call_with_connection_and_prepared ( func ) : <EOL> arg_names , varargs , varkwargs , defaults = getargspec ( func ) <EOL> updated = ( <EOL> ( '<STR_LIT>' in arg_names or varkwargs ) and <EOL> ( '<STR_LIT>' in arg_names or varkwargs ) <EOL> ) <EOL> if not updated : <EOL> warn ( "<STR_LIT>" <EOL> "<STR_LIT>" % func . __name__ , <EOL> DeprecationWarning , stacklevel = <NUM_LIT:3> ) <EOL> def inner ( * args , ** kwargs ) : <EOL> if '<STR_LIT>' not in kwargs : <EOL> from django . db import connection <EOL> kwargs [ '<STR_LIT>' ] = connection <EOL> warn ( "<STR_LIT>" % <EOL> func . __name__ , DeprecationWarning , <EOL> stacklevel = <NUM_LIT:2> ) <EOL> if updated : <EOL> return func ( * args , ** kwargs ) <EOL> if '<STR_LIT>' in kwargs : <EOL> del kwargs [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in kwargs : <EOL> del kwargs [ '<STR_LIT>' ] <EOL> return func ( * args , ** kwargs ) <EOL> return inner <EOL> class LegacyConnection ( type ) : <EOL> """<STR_LIT>""" <EOL> def __new__ ( cls , name , bases , attrs ) : <EOL> new_cls = super ( LegacyConnection , cls ) . __new__ ( cls , name , bases , attrs ) <EOL> for attr in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> setattr ( new_cls , attr , call_with_connection ( getattr ( new_cls , attr ) ) ) <EOL> for attr in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> setattr ( new_cls , attr , call_with_connection_and_prepared ( getattr ( new_cls , attr ) ) ) <EOL> return new_cls <EOL> class SubfieldBase ( LegacyConnection ) : <EOL> """<STR_LIT>""" <EOL> def __new__ ( cls , name , bases , attrs ) : <EOL> new_class = super ( SubfieldBase , cls ) . __new__ ( cls , name , bases , attrs ) <EOL> new_class . contribute_to_class = make_contrib ( <EOL> new_class , attrs . get ( '<STR_LIT>' ) <EOL> ) <EOL> return new_class <EOL> class Creator ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , field ) : <EOL> self . field = field <EOL> def __get__ ( self , obj , type = None ) : <EOL> if obj is None : <EOL> raise AttributeError ( '<STR_LIT>' ) <EOL> return obj . __dict__ [ self . field . name ] <EOL> def __set__ ( self , obj , value ) : <EOL> obj . __dict__ [ self . field . name ] = self . field . to_python ( value ) <EOL> def make_contrib ( superclass , func = None ) : <EOL> """<STR_LIT>""" <EOL> def contribute_to_class ( self , cls , name ) : <EOL> if func : <EOL> func ( self , cls , name ) <EOL> else : <EOL> super ( superclass , self ) . contribute_to_class ( cls , name ) <EOL> setattr ( cls , self . name , Creator ( self ) ) <EOL> return contribute_to_class </s>
