Skip to content

Commit

Permalink
Allow easier customizations
Browse files Browse the repository at this point in the history
  • Loading branch information
ale-rt committed Apr 19, 2018
1 parent c5358f2 commit a20d535
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Breaking changes:

New features:

- Target Zope 4 (test chnages only).
- It is now possible to customize in an easier way the ``@@images`` view
[ale-rt]
- Target Zope 4 (test changes only).

Bug fixes:

Expand Down
14 changes: 10 additions & 4 deletions plone/namedfile/scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import logging
import six


logger = logging.getLogger(__name__)
_marker = object()

Expand Down Expand Up @@ -282,6 +283,7 @@ class ImageScaling(BrowserView):
# Ignore some stacks to help with accessing via webdav, otherwise you get a
# 404 NotFound error.
_ignored_stacks = ('manage_DAVget', 'manage_FTPget')
_scale_view_class = ImageScale

def publishTraverse(self, request, name):
""" used for traversal via publisher, i.e. when using as a url """
Expand All @@ -301,15 +303,19 @@ def publishTraverse(self, request, name):
info = storage.get(name)
if info is None:
raise NotFound(self, name, self.request)
scale_view = ImageScale(self.context, self.request, **info)
scale_view = self._scale_view_class(
self.context,
self.request,
**info
)
alsoProvides(scale_view, IStableImageScale)
return scale_view
else:
# otherwise `name` must refer to a field...
if '.' in name:
name, ext = name.rsplit('.', 1)
value = getattr(self.context, name)
scale_view = ImageScale(
scale_view = self._scale_view_class(
self.context,
self.request,
data=value,
Expand All @@ -323,7 +329,7 @@ def traverse(self, name, furtherPath):
# validate access
value = self.guarded_orig_image(name)
if not furtherPath:
image = ImageScale(
image = self._scale_view_class(
self.context,
self.request,
data=value,
Expand Down Expand Up @@ -445,7 +451,7 @@ def scale(
**parameters
)
info['fieldname'] = fieldname
scale_view = ImageScale(self.context, self.request, **info)
scale_view = self._scale_view_class(self.context, self.request, **info)
return scale_view

def calculate_srcset(
Expand Down

1 comment on commit a20d535

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

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

@ale-rt Jenkins CI reporting about code analysis
See the full report here: https://jenkins.plone.org/job/package-plone.namedfile/76/violations

plone/namedfile/marshaler.py:67:36: C812 missing trailing comma
plone/namedfile/storages.py:12:1: I003 isort expected 1 blank line in imports, found 0
plone/namedfile/testing.py:18:9: D001 found xmlconfig.file( replace it with self.loadZCML(
plone/namedfile/testing.py:22:36: C812 missing trailing comma
plone/namedfile/file.py:25:1: I003 isort expected 1 blank line in imports, found 0
plone/namedfile/file.py:261:9: Q001 Remove bad quotes from multiline string.
plone/namedfile/file.py:302:9: Q001 Remove bad quotes from multiline string.
plone/namedfile/handler.py:11:23: C812 missing trailing comma
plone/namedfile/interfaces.py:17:25: C812 missing trailing comma
plone/namedfile/scaling.py:193:25: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:196:5: C901 'DefaultImageScalingFactory.__call__' is too complex (15)
plone/namedfile/scaling.py:203:25: C816 missing trailing comma in Python 3.6+
plone/namedfile/scaling.py:243:29: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:309:23: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:412:21: C816 missing trailing comma in Python 3.6+
plone/namedfile/scaling.py:439:25: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:451:25: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:465:21: C816 missing trailing comma in Python 3.6+
plone/namedfile/scaling.py:491:29: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:505:17: C816 missing trailing comma in Python 3.6+
plone/namedfile/utils/__init__.py:19:1: I003 isort expected 1 blank line in imports, found 0
plone/namedfile/utils/__init__.py:83:66: C812 missing trailing comma
plone/namedfile/utils/__init__.py:150:15: T000 Todo note found.
plone/namedfile/utils/__init__.py:155:73: C812 missing trailing comma
plone/namedfile/utils/__init__.py:175:15: T000 Todo note found.
plone/namedfile/utils/__init__.py:182:18: C812 missing trailing comma
plone/namedfile/utils/__init__.py:187:1: C901 'rotate_image' is too complex (20)
plone/namedfile/utils/__init__.py:218:14: C812 missing trailing comma
plone/namedfile/utils/__init__.py:275:1: E302 expected 2 blank lines, found 1
plone/namedfile/utils/__init__.py:279:1: E302 expected 2 blank lines, found 1
plone/namedfile/utils/tiff_utils.py:11:1: C901 'process_tiff' is too complex (11)
plone/namedfile/utils/tiff_utils.py:20:7: T000 Todo note found.
plone/namedfile/utils/tiff_utils.py:81:7: T000 Todo note found.
plone/namedfile/utils/tiff_utils.py:82:7: T000 Todo note found.
plone/namedfile/tests/test_blobfile.py:40:31: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:45:35: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:50:46: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:55:32: C812 missing trailing comma
plone/namedfile/tests/test_scaling.py:85:80: E501 line too long (86 > 79 characters)
plone/namedfile/tests/test_scaling.py:102:80: E501 line too long (81 > 79 characters)
plone/namedfile/tests/test_scaling.py:133:80: E501 line too long (86 > 79 characters)
plone/namedfile/tests/test_scaling.py:156:80: E501 line too long (86 > 79 characters)
plone/namedfile/tests/test_scaling.py:178:80: E501 line too long (86 > 79 characters)
plone/namedfile/tests/test_scaling.py:200:80: E501 line too long (86 > 79 characters)
plone/namedfile/tests/test_doctests.py:25:51: C812 missing trailing comma
plone/namedfile/tests/test_doctests.py:27:10: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:116:28: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:146:70: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:153:76: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:164:74: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:197:75: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:202:78: C812 missing trailing comma

Follow these instructions to reproduce it locally.

Please sign in to comment.