prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  302 Status in Shipping Method. 
  **TD;LR** When I enter the "Shipping Address" entire as anonymous or create a new address. It makes me submit it again and again.
  
  Using c79bdbb13c399b253e3a26480d01f1cb219b4700
  
  I get this most annoying bug. I can't solve from days. It only happens in the production site, not on the test as well as development. I really don't understand where I am going wrong.
  
  What should really happen `Shipping Address(302) -> Shipping Method(200)`
  
  Problem:
  `Shipping Address(302) -> Shipping Method(302) -> Shipping Address(200)`.
  This mean the users has to submit the form again and again.
  
  Cases when `Shipping Method(200)` 
  - 3 to 5 attempts of submitting the form.
  - 2 to 5 minutes of waiting to submit again.
  
  I have even done an attempt using the `old checkout`, when the billing address was the first form, Still result is the same.
  
  
  </issue>
  <code>
  [start of saleor/core/__init__.py]
  1 from __future__ import unicode_literals
  2 
  3 from babel.numbers import get_territory_currencies
  4 from django.conf import settings
  5 from django_countries import countries
  6 from django_countries.fields import Country
  7 from geolite2 import geolite2
  8 
  9 TOKEN_PATTERN = ('(?P<token>[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}'
  10                  '-[0-9a-z]{12})')
  11 
  12 
  13 def get_country_by_ip(ip_address):
  14     reader = geolite2.reader()
  15     geo_data = reader.get(ip_address)
  16     geolite2.close()
  17     if geo_data and 'country' in geo_data and 'iso_code' in geo_data['country']:
  18         country_iso_code = geo_data['country']['iso_code']
  19         if country_iso_code in countries:
  20             return Country(country_iso_code)
  21 
  22 
  23 def get_currency_for_country(country):
  24     currencies = get_territory_currencies(country.code)
  25     if len(currencies):
  26         main_currency = currencies[0]
  27         if main_currency in settings.AVAILABLE_CURRENCIES:
  28             return main_currency
  29     return settings.DEFAULT_CURRENCY
  30
  [end of saleor/core/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/saleor/core/__init__.py b/saleor/core/__init__.py
  --- a/saleor/core/__init__.py
  +++ b/saleor/core/__init__.py
  @@ -2,6 +2,7 @@
   
   from babel.numbers import get_territory_currencies
   from django.conf import settings
  +from django.core.checks import register, Tags, Warning
   from django_countries import countries
   from django_countries.fields import Country
   from geolite2 import geolite2
  @@ -27,3 +28,19 @@
           if main_currency in settings.AVAILABLE_CURRENCIES:
               return main_currency
       return settings.DEFAULT_CURRENCY
  +
  +
  +@register()
  +def check_session_caching(app_configs, **kwargs):
  +    errors = []
  +    cached_engines = {
  +        'django.contrib.sessions.backends.cache',
  +        'django.contrib.sessions.backends.cached_db'}
  +    if ('locmem' in settings.CACHES['default']['BACKEND'] and
  +            settings.SESSION_ENGINE in cached_engines):
  +        errors.append(
  +            Warning(
  +                'Session caching cannot work with locmem backend',
  +                'User sessions need to be globally shared, use a cache server like Redis.',
  +                'saleor.W001'))
  +    return errors
  
verification_info: {"golden_diff": "diff --git a/saleor/core/__init__.py b/saleor/core/__init__.py\n--- a/saleor/core/__init__.py\n+++ b/saleor/core/__init__.py\n@@ -2,6 +2,7 @@\n \n from babel.numbers import get_territory_currencies\n from django.conf import settings\n+from django.core.checks import register, Tags, Warning\n from django_countries import countries\n from django_countries.fields import Country\n from geolite2 import geolite2\n@@ -27,3 +28,19 @@\n         if main_currency in settings.AVAILABLE_CURRENCIES:\n             return main_currency\n     return settings.DEFAULT_CURRENCY\n+\n+\n+@register()\n+def check_session_caching(app_configs, **kwargs):\n+    errors = []\n+    cached_engines = {\n+        'django.contrib.sessions.backends.cache',\n+        'django.contrib.sessions.backends.cached_db'}\n+    if ('locmem' in settings.CACHES['default']['BACKEND'] and\n+            settings.SESSION_ENGINE in cached_engines):\n+        errors.append(\n+            Warning(\n+                'Session caching cannot work with locmem backend',\n+                'User sessions need to be globally shared, use a cache server like Redis.',\n+                'saleor.W001'))\n+    return errors\n", "issue": "302 Status in Shipping Method. \n**TD;LR** When I enter the \"Shipping Address\" entire as anonymous or create a new address. It makes me submit it again and again.\n\nUsing c79bdbb13c399b253e3a26480d01f1cb219b4700\n\nI get this most annoying bug. I can't solve from days. It only happens in the production site, not on the test as well as development. I really don't understand where I am going wrong.\n\nWhat should really happen `Shipping Address(302) -> Shipping Method(200)`\n\nProblem:\n`Shipping Address(302) -> Shipping Method(302) -> Shipping Address(200)`.\nThis mean the users has to submit the form again and again.\n\nCases when `Shipping Method(200)` \n- 3 to 5 attempts of submitting the form.\n- 2 to 5 minutes of waiting to submit again.\n\nI have even done an attempt using the `old checkout`, when the billing address was the first form, Still result is the same.\n\n", "before_files": [{"content": "from __future__ import unicode_literals\n\nfrom babel.numbers import get_territory_currencies\nfrom django.conf import settings\nfrom django_countries import countries\nfrom django_countries.fields import Country\nfrom geolite2 import geolite2\n\nTOKEN_PATTERN = ('(?P<token>[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}'\n                 '-[0-9a-z]{12})')\n\n\ndef get_country_by_ip(ip_address):\n    reader = geolite2.reader()\n    geo_data = reader.get(ip_address)\n    geolite2.close()\n    if geo_data and 'country' in geo_data and 'iso_code' in geo_data['country']:\n        country_iso_code = geo_data['country']['iso_code']\n        if country_iso_code in countries:\n            return Country(country_iso_code)\n\n\ndef get_currency_for_country(country):\n    currencies = get_territory_currencies(country.code)\n    if len(currencies):\n        main_currency = currencies[0]\n        if main_currency in settings.AVAILABLE_CURRENCIES:\n            return main_currency\n    return settings.DEFAULT_CURRENCY\n", "path": "saleor/core/__init__.py"}]}