Skip to content

Commit

Permalink
Update fileextension.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrebron authored Sep 7, 2019
1 parent 69d5063 commit d2bc7b8
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions plone/app/contentrules/conditions/fileextension.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
from zope.component import adapter
from zope.interface import implementer
from zope.interface import Interface


from plone.app.contenttypes.interfaces import IFile
try:
from Products.ATContentTypes.interfaces import IFileContent
except ImportError:
Expand Down Expand Up @@ -65,17 +64,21 @@ def __init__(self, context, element, event):

def __call__(self):
obj = self.event.object
if IFileContent is None:
return False
if not IFileContent.providedBy(obj):
return False

base_unit = obj.getFile()
get_filename = getattr(base_unit, 'getFilename', None)
if not get_filename:
if IFile.providedBy(obj):
base_unit = getattr(obj, 'file', None)
name = getattr(base_unit, 'filename', None)
elif IFileContent is None:
return False
elif not IFileContent.providedBy(obj):
return False
else:
base_unit = obj.getFile()
get_filename = getattr(base_unit, 'getFilename', None)
if not get_filename:
return False
name = get_filename()

name = get_filename()
extension = name[name.rfind('.') + 1:]
return extension == self.element.file_extension

Expand Down

0 comments on commit d2bc7b8

Please sign in to comment.