Skip to content

Commit

Permalink
bug 1100354 - fix fields mutations (mozilla-services#3946)
Browse files Browse the repository at this point in the history
Super search fields come from a Python module now and are handed around and some
of the users mutate the value. Because of that, we want to hand around a copy of
the structure--not the structure itself. This fixes that.

Additionally, this cleans up some comments that were wrong because we're not
storing the fields in JSON anymore.
  • Loading branch information
willkg authored Aug 29, 2017
1 parent 4144894 commit 1d52693
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def read(fname):
test_suite='nose.collector',
zip_safe=False,
data_files=[
('socorro/external/es/data', glob.glob('socorro/external/es/data/*.json')),
('socorro/external/postgresql/raw_sql/procs',
glob.glob('socorro/external/postgresql/raw_sql/procs/*.sql')),
('socorro/external/postgresql/raw_sql/views',
Expand Down
11 changes: 6 additions & 5 deletions webapp-django/crashstats/supersearch/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import functools

from socorro.external.es import query
Expand Down Expand Up @@ -41,7 +42,7 @@ class SuperSearchFieldsWithoutConfig(super_search_fields.SuperSearchFields):
needed to reach Elasticsearch.
This way we can call `.get()` on an instance of this class, which
just reads a .json file.
just returns the fields.
"""

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -232,15 +233,15 @@ def get(self, **kwargs):

class SuperSearchFields(ESSocorroMiddleware):

# Read it in once as a class attribute since it'll never change
# unless the .json file on disk changes and if that happens you
# will have reloaded the Python process.
# Read it in once as a class attribute since it'll never change unless the
# Python code changes and if that happens you will have reloaded the
# Python process.
_fields = SuperSearchFieldsWithoutConfig().get()

API_WHITELIST = None

def get(self):
return self._fields
return copy.deepcopy(self._fields)


class SuperSearchMissingFields(ESSocorroMiddleware):
Expand Down

0 comments on commit 1d52693

Please sign in to comment.