<s> import importlib <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> from django . utils . translation import ugettext as _ <EOL> from cms . utils . conf import get_cms_setting <EOL> def get_request_ip_resolver ( ) : <EOL> """<STR_LIT>""" <EOL> module , attribute = get_cms_setting ( '<STR_LIT>' ) . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) <EOL> try : <EOL> ip_resolver_module = importlib . import_module ( module ) <EOL> ip_resolver = getattr ( ip_resolver_module , attribute ) <EOL> except ImportError : <EOL> raise ImproperlyConfigured ( <EOL> _ ( '<STR_LIT>' <EOL> '<STR_LIT>' ) % module ) <EOL> except AttributeError : <EOL> raise ImproperlyConfigured ( <EOL> _ ( '<STR_LIT>' <EOL> '<STR_LIT>' ) % ( attribute , module , ) ) <EOL> return ip_resolver <EOL> def default_request_ip_resolver ( request ) : <EOL> """<STR_LIT>""" <EOL> return ( <EOL> real_ip ( request ) or <EOL> x_forwarded_ip ( request ) or <EOL> remote_addr_ip ( request ) <EOL> ) <EOL> def real_ip ( request ) : <EOL> """<STR_LIT>""" <EOL> return request . META . get ( '<STR_LIT>' ) <EOL> def remote_addr_ip ( request ) : <EOL> """<STR_LIT>""" <EOL> return request . META . get ( '<STR_LIT>' ) <EOL> def x_forwarded_ip ( request ) : <EOL> """<STR_LIT>""" <EOL> ip_address_list = request . META . get ( '<STR_LIT>' ) <EOL> if ip_address_list : <EOL> ip_address_list = ip_address_list . split ( '<STR_LIT:U+002C>' ) <EOL> return ip_address_list [ <NUM_LIT:0> ] </s>
