Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warnings #38

Merged
merged 18 commits into from
Aug 10, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/Products/PluginIndexes/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#
##############################################################################

_marker = []


class RequestCache(dict):

Expand All @@ -22,13 +20,11 @@ class RequestCache(dict):
_sets = 0

def get(self, key, default=None):
value = super(RequestCache, self).get(key, _marker)

if value is _marker:
self._misses += 1
try:
value = self[key]
except KeyError:
return default

self._hits += 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand, why this method used to set _misses and _hits, but does not need it anymore. As it seems to be actually a tool for testing, it should be fine, if nothing breaks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "get" method now calls the"getitem" method (see self[key]), which still sets the variables"_hits" and"_misses". Other tests using the method will therefore continue to work.

return value

def __getitem__(self, key):
Expand Down Expand Up @@ -58,5 +54,6 @@ def stats(self):
return stats

def __str__(self):
return '<RequestCache {0} items (hits: {1}, misses: {2}, \
sets: {3})>'.format(len(self), self._hits, self._misses, self._sets)
return ('<RequestCache {0} items (hits: {1}, misses: {2},',
' sets: {3})>').format(len(self), self._hits,
self._misses, self._sets)