-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move imaging control panel to cmfplone
- Loading branch information
Showing
9 changed files
with
98 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from Products.CMFPlone import PloneMessageFactory as _ | ||
from Products.CMFPlone.interfaces.controlpanel import IImagingSchema | ||
from logging import getLogger | ||
from plone.app.registry.browser import controlpanel | ||
|
||
log = getLogger('Plone') | ||
|
||
|
||
class ImagingControlPanelForm(controlpanel.RegistryEditForm): | ||
|
||
id = "ImagingSettings" | ||
label = _(u"Image Handling") | ||
schema = IImagingSchema | ||
schema_prefix = "plone" | ||
|
||
|
||
class ImagingControlPanel(controlpanel.ControlPanelFormWrapper): | ||
form = ImagingControlPanelForm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0"?> | ||
<metadata> | ||
<version>5004</version> | ||
<version>5005</version> | ||
</metadata> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
from zope.deprecation import deprecated | ||
from zope.i18n import translate | ||
from zope.publisher.interfaces.browser import IBrowserRequest | ||
from zope import schema | ||
|
||
import OFS | ||
from AccessControl import getSecurityManager, Unauthorized | ||
|
@@ -30,10 +31,10 @@ | |
from App.ImageFile import ImageFile | ||
from DateTime import DateTime | ||
from DateTime.interfaces import DateTimeError | ||
from Products.CMFCore.interfaces import IPropertiesTool | ||
from Products.CMFCore.permissions import ManageUsers | ||
from Products.CMFCore.utils import ToolInit as CMFCoreToolInit | ||
from Products.CMFCore.utils import getToolByName | ||
from Products.CMFPlone import PloneMessageFactory as _ | ||
|
||
import transaction | ||
|
||
|
@@ -62,8 +63,8 @@ | |
|
||
# Log methods | ||
from log import log | ||
from log import log_exc | ||
from log import log_deprecated | ||
from log import log_exc # noqa | ||
from log import log_deprecated # noqa | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
thet
Member
|
||
|
||
_marker = [] | ||
|
||
|
@@ -125,7 +126,7 @@ def isIDAutoGenerated(context, id): | |
|
||
pt = getToolByName(context, 'portal_types') | ||
portaltypes = pt.listContentTypes() | ||
portaltypes.extend([pt.lower() for pt in portaltypes]) | ||
portaltypes.extend([t.lower() for t in portaltypes]) | ||
|
||
try: | ||
parts = id.split('.') | ||
|
@@ -135,8 +136,7 @@ def isIDAutoGenerated(context, id): | |
type = ' '.join(obj_type.split('_')) | ||
# New autogenerated ids may have a lower case portal type | ||
if ((type in portaltypes or obj_type in portaltypes) and | ||
DateTime(date_created) and | ||
float(random_number)): | ||
DateTime(date_created) and float(random_number)): | ||
return True | ||
except (ValueError, AttributeError, IndexError, DateTimeError): | ||
pass | ||
|
@@ -182,9 +182,9 @@ def pretty_title_or_id(context, obj, empty_value=_marker): | |
of whether obj is a catalog brain or an object, but returning an | ||
empty title marker if the id is not set (i.e. it's auto-generated). | ||
""" | ||
#if safe_hasattr(obj, 'aq_explicit'): | ||
# if safe_hasattr(obj, 'aq_explicit'): | ||
# obj = obj.aq_explicit | ||
#title = getattr(obj, 'Title', None) | ||
# title = getattr(obj, 'Title', None) | ||
title = None | ||
if base_hasattr(obj, 'Title'): | ||
title = getattr(obj, 'Title', None) | ||
|
@@ -561,20 +561,20 @@ def _unrestricted_rename(container, id, new_id): | |
try: | ||
container._checkId(new_id) | ||
except: | ||
raise CopyError, MessageDialog( | ||
title='Invalid Id', | ||
message=sys.exc_info()[1], | ||
action='manage_main') | ||
raise CopyError(MessageDialog( | ||
title='Invalid Id', | ||
message=sys.exc_info()[1], | ||
action='manage_main')) | ||
ob = container._getOb(id) | ||
if not ob.cb_isMoveable(): | ||
raise CopyError, eNotSupported % escape(id) | ||
raise CopyError(eNotSupported % escape(id)) | ||
try: | ||
ob._notifyOfCopyTo(container, op=1) | ||
except: | ||
raise CopyError, MessageDialog( | ||
title='Rename Error', | ||
message=sys.exc_info()[1], | ||
action='manage_main') | ||
raise CopyError(MessageDialog( | ||
title='Rename Error', | ||
message=sys.exc_info()[1], | ||
action='manage_main')) | ||
container._delObject(id) | ||
ob = aq_base(ob) | ||
ob._setId(new_id) | ||
|
@@ -677,40 +677,8 @@ def set_own_login_name(member, loginname): | |
pas.updateLoginName(member.getId(), loginname) | ||
|
||
|
||
def getAllowedSizes(): | ||
"""Get image-scale sizes. | ||
""" | ||
ptool = queryUtility(IPropertiesTool) | ||
if ptool is None: | ||
return None | ||
props = getattr(ptool, 'imaging_properties', None) | ||
if props is None: | ||
return None | ||
sizes = {} | ||
for line in props.getProperty('allowed_sizes'): | ||
line = line.strip() | ||
if line: | ||
name, width, height = pattern.match(line).groups() | ||
name = name.strip().replace(' ', '_') | ||
sizes[name] = int(width), int(height) | ||
return sizes | ||
|
||
|
||
def getQuality(): | ||
"""Get quality used in image-scaling | ||
""" | ||
ptool = queryUtility(IPropertiesTool) | ||
if ptool: | ||
props = getattr(ptool, 'imaging_properties', None) | ||
if props: | ||
quality = props.getProperty('quality') | ||
if quality: | ||
return quality | ||
return QUALITY_DEFAULT | ||
|
||
|
||
def ajax_load_url(url): | ||
if url and not 'ajax_load' in url: | ||
if url and 'ajax_load' not in url: | ||
sep = '?' in url and '&' or '?' # url parameter seperator | ||
url = '%s%sajax_load=1' % (url, sep) | ||
return url | ||
|
@@ -746,3 +714,14 @@ def bodyfinder(text): | |
if bodyend == -1: | ||
return text | ||
return text[bodystart:bodyend] | ||
|
||
|
||
# XXX nasty? better than re-writting same method. Circular import issues here | ||
def getAllowedSizes(): | ||
from plone.app.imaging.utils import getAllowedSizes as func | ||
return func() | ||
|
||
|
||
def getQuality(): | ||
from plone.app.imaging.utils import getQuality as func | ||
return func() |
@vangheem Which tool is actually influenced by this
noqa
comment? It has no effect for pyflakes or pep8, at least not the way I have set it up.When an import like this is not used, which pyflakes complains about, but we still want to keep it, I always add a line that simply mentions the import. And I add a comment
# pyflakes
at this new line, which has no influence on any tools, but only serves as an explanation for developers on why this line is there. So:I have also seen the following in other files:
This also has no effect on tools that I know. If pep8 listens to this, then that is nice, but pyflakes will still warn that the import is unused.
I am just wondering if I am missing some other tool, or a different way of setting things up.