Skip to content

Commit 4ab2fe5

Browse files
committed
Don't run ietf.checks.* more than once per invocation (under Django 1.7, these can be run more times than there are apps with migrations, posibly as many times as twice that number).
- Legacy-Id: 12239
1 parent 6e46de4 commit 4ab2fe5

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

ietf/checks.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,24 @@
44
from textwrap import dedent
55

66
import debug # pyflakes:ignore
7+
debug.debug = True
78

89
from django.conf import settings
910
from django.core import checks
1011
from django.utils.module_loading import import_string
1112

13+
checks_run = []
14+
15+
def already_ran():
16+
import inspect
17+
outerframe = inspect.currentframe().f_back
18+
name = outerframe.f_code.co_name
19+
if name in checks_run:
20+
return True
21+
else:
22+
check_run.append(name)
23+
return False
24+
1225
@checks.register('directories')
1326
def check_cdn_directory_exists(app_configs, **kwargs):
1427
"""This checks that the path from which the CDN will serve static files for
@@ -17,6 +30,9 @@ def check_cdn_directory_exists(app_configs, **kwargs):
1730
set to a different part of the file system which is served via CDN, and the
1831
path will contain the datatracker release version.
1932
"""
33+
if already_ran():
34+
return []
35+
#
2036
errors = []
2137
if settings.SERVER_MODE == 'production' and not os.path.exists(settings.STATIC_ROOT):
2238
errors.append(checks.Error(
@@ -30,6 +46,10 @@ def check_cdn_directory_exists(app_configs, **kwargs):
3046
@checks.register('files')
3147
def check_group_email_aliases_exists(app_configs, **kwargs):
3248
from ietf.group.views import check_group_email_aliases
49+
#
50+
if already_ran():
51+
return []
52+
#
3353
errors = []
3454
try:
3555
ok = check_group_email_aliases()
@@ -53,6 +73,10 @@ def check_group_email_aliases_exists(app_configs, **kwargs):
5373
@checks.register('files')
5474
def check_doc_email_aliases_exists(app_configs, **kwargs):
5575
from ietf.doc.views_doc import check_doc_email_aliases
76+
#
77+
if already_ran():
78+
return []
79+
#
5680
errors = []
5781
try:
5882
ok = check_doc_email_aliases()
@@ -75,6 +99,10 @@ def check_doc_email_aliases_exists(app_configs, **kwargs):
7599

76100
@checks.register('directories')
77101
def check_id_submission_directories(app_configs, **kwargs):
102+
#
103+
if already_ran():
104+
return []
105+
#
78106
errors = []
79107
for s in ("IDSUBMIT_STAGING_PATH", "IDSUBMIT_REPOSITORY_PATH", "INTERNET_DRAFT_ARCHIVE_DIR", ):
80108
p = getattr(settings, s)
@@ -91,6 +119,10 @@ def check_id_submission_directories(app_configs, **kwargs):
91119

92120
@checks.register('files')
93121
def check_id_submission_files(app_configs, **kwargs):
122+
#
123+
if already_ran():
124+
return []
125+
#
94126
errors = []
95127
for s in ("IDSUBMIT_IDNITS_BINARY", ):
96128
p = getattr(settings, s)
@@ -107,6 +139,10 @@ def check_id_submission_files(app_configs, **kwargs):
107139

108140
@checks.register('submission-checkers')
109141
def check_id_submission_checkers(app_configs, **kwargs):
142+
#
143+
if already_ran():
144+
return []
145+
#
110146
errors = []
111147
for checker_path in settings.IDSUBMIT_CHECKER_CLASSES:
112148
try:
@@ -150,6 +186,10 @@ def check_id_submission_checkers(app_configs, **kwargs):
150186

151187
@checks.register('directories')
152188
def check_media_directories(app_configs, **kwargs):
189+
#
190+
if already_ran():
191+
return []
192+
#
153193
errors = []
154194
for s in ("PHOTOS_DIR", ):
155195
p = getattr(settings, s)
@@ -167,6 +207,10 @@ def check_media_directories(app_configs, **kwargs):
167207

168208
@checks.register('directories')
169209
def check_proceedings_directories(app_configs, **kwargs):
210+
#
211+
if already_ran():
212+
return []
213+
#
170214
errors = []
171215
for s in ("AGENDA_PATH", ):
172216
p = getattr(settings, s)
@@ -183,6 +227,10 @@ def check_proceedings_directories(app_configs, **kwargs):
183227

184228
@checks.register('cache')
185229
def check_cache(app_configs, **kwargs):
230+
#
231+
if already_ran():
232+
return []
233+
#
186234
errors = []
187235
if settings.SERVER_MODE == 'production':
188236
from django.core.cache import cache
@@ -215,6 +263,10 @@ def cache_error(msg, errnum):
215263

216264
@checks.register('cache')
217265
def check_svn_import(app_configs, **kwargs):
266+
#
267+
if already_ran():
268+
return []
269+
#
218270
errors = []
219271
#
220272
site_packages_dir = None

0 commit comments

Comments
 (0)