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

Image scales cache does not work in tests #58

Open
rafaelbco opened this issue Sep 21, 2017 · 1 comment
Open

Image scales cache does not work in tests #58

rafaelbco opened this issue Sep 21, 2017 · 1 comment

Comments

@rafaelbco
Copy link
Member

I recently updated from 2.0.9 to 3.0.11 in my buildout and noticed some test failures. I was able to identify the problem: when running tests, the image scales cache does not work.

The reason is in the following lines:

def modified(self):
"""Provide a callable to return the modification time of content
items, so stored image scales can be invalidated.
"""
context = aq_base(self.context)
date = DateTime(context._p_mtime)
return date.millis()

During tests, a content item may have the _p_mtime attribute set to None. So the code above is actually doing DateTime(None), which returns the current date/time. The result is every time a scale is requested it considers the cached value invalid, because the object is considered modified.

In the old version context.modified() was used instead of _p_mtime, and this method always returned a non-None value.

I wonder how to solve this problem. Maybe modified should return a default date in the past?

@rafaelbco
Copy link
Member Author

Note: this bug still happens in version 5.6.0 which is used by Plone 5.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant