diff --git a/src/pretix/base/services/tax.py b/src/pretix/base/services/tax.py index b34f48efb5..f385bfd241 100644 --- a/src/pretix/base/services/tax.py +++ b/src/pretix/base/services/tax.py @@ -20,11 +20,13 @@ # . # import logging +import os import re from urllib.error import HTTPError import vat_moss.errors import vat_moss.id +from django.conf import settings from django.utils.translation import gettext_lazy as _ from zeep import Client, Transport from zeep.cache import SqliteCache @@ -83,7 +85,7 @@ def _validate_vat_id_CH(vat_id, country_code): vat_id = re.sub('[^A-Z0-9]', '', vat_id.replace('HR', '').replace('MWST', '')) try: - transport = Transport(cache=SqliteCache()) + transport = Transport(cache=SqliteCache(os.path.join(settings.CACHE_DIR, "validate_vat_id_ch_zeep_cache.db"))) client = Client( 'https://www.uid-wse-a.admin.ch/V5.0/PublicServices.svc?wsdl', transport=transport diff --git a/src/pretix/settings.py b/src/pretix/settings.py index b1050b6165..c848b1c3f0 100644 --- a/src/pretix/settings.py +++ b/src/pretix/settings.py @@ -67,6 +67,7 @@ DATA_DIR = config.get('pretix', 'datadir', fallback=os.environ.get('DATA_DIR', ' LOG_DIR = os.path.join(DATA_DIR, 'logs') MEDIA_ROOT = os.path.join(DATA_DIR, 'media') PROFILE_DIR = os.path.join(DATA_DIR, 'profiles') +CACHE_DIR = os.path.join(DATA_DIR, 'cache') if not os.path.exists(DATA_DIR): os.mkdir(DATA_DIR) @@ -74,6 +75,8 @@ if not os.path.exists(LOG_DIR): os.mkdir(LOG_DIR) if not os.path.exists(MEDIA_ROOT): os.mkdir(MEDIA_ROOT) +if not os.path.exists(CACHE_DIR): + os.mkdir(CACHE_DIR) if config.has_option('django', 'secret'): SECRET_KEY = config.get('django', 'secret')