Updated imports for last "pyams_file" package version
authorThierry Florac <tflorac@ulthar.net>
Mon, 20 Jul 2020 15:07:41 +0200
changeset 1411 cd12f6f824e2
parent 1410 94a8e382238f
child 1412 5a4cc99b8253
Updated imports for last "pyams_file" package version
src/pyams_content/component/paragraph/zmi/pictogram.py
src/pyams_content/reference/pictograms/zmi/__init__.py
--- a/src/pyams_content/component/paragraph/zmi/pictogram.py	Mon Jul 20 14:08:32 2020 +0200
+++ b/src/pyams_content/component/paragraph/zmi/pictogram.py	Mon Jul 20 15:07:41 2020 +0200
@@ -10,8 +10,6 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
-__docformat__ = 'restructuredtext'
-
 import json
 
 from pyramid.decorator import reify
@@ -25,17 +23,18 @@
 
 from pyams_content.component.paragraph import BaseParagraph
 from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget
-from pyams_content.component.paragraph.interfaces.pictogram import IPictogramContainer, IPictogramContainerTarget, \
-    IPictogramItem, IPictogramParagraph, PICTOGRAM_PARAGRAPH_TYPE
+from pyams_content.component.paragraph.interfaces.pictogram import IPictogramContainer, \
+    IPictogramContainerTarget, IPictogramItem, IPictogramParagraph, PICTOGRAM_PARAGRAPH_TYPE
 from pyams_content.component.paragraph.pictogram import PictogramItem, PictogramParagraph
-from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \
-    BaseParagraphAddForm, BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons
+from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, \
+    BaseParagraphAJAXEditForm, BaseParagraphAddForm, BaseParagraphAddMenu, \
+    BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons
 from pyams_content.component.paragraph.zmi import IParagraphContainerView
 from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
 from pyams_content.reference.pictograms.zmi.widget import PictogramSelectFieldWidget
 from pyams_content.shared.common import IWfSharedContent
-from pyams_file.zmi.image import render_image
+from pyams_file.image import render_image
 from pyams_form.form import AJAXAddForm, ajax_config
 from pyams_form.interfaces.form import IInnerForm, IInnerSubForm
 from pyams_form.security import ProtectedFormObjectMixin
@@ -43,11 +42,12 @@
 from pyams_i18n.interfaces import II18n
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.container import switch_element_visibility
-from pyams_skin.event import get_json_switched_table_refresh_event, get_json_table_row_refresh_event, \
-    get_json_widget_refresh_event
+from pyams_skin.event import get_json_switched_table_refresh_event, \
+    get_json_table_row_refresh_event, get_json_widget_refresh_event
 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu, IWidgetTitleViewletManager
 from pyams_skin.layer import IPyAMSLayer
-from pyams_skin.table import BaseTable, I18nColumn, SorterColumn, TrashColumn, VisibilitySwitcherColumn
+from pyams_skin.table import BaseTable, I18nColumn, SorterColumn, TrashColumn, \
+    VisibilitySwitcherColumn
 from pyams_skin.viewlet.toolbar import ToolbarAction
 from pyams_utils.adapter import ContextRequestViewAdapter, adapter_config
 from pyams_utils.text import get_text_start
@@ -58,6 +58,9 @@
 from pyams_zmi.interfaces import IPropertiesEditForm
 from pyams_zmi.zmi.table import InnerTableView
 
+
+__docformat__ = 'restructuredtext'
+
 from pyams_content import _
 
 
@@ -69,8 +72,9 @@
     """Pictograms parent form marker interface"""
 
 
-@viewlet_config(name='add-pictogram-paragraph.menu', context=IParagraphContainerTarget, view=IParagraphContainerView,
-                layer=IPyAMSLayer, manager=IToolbarAddingMenu, weight=600)
+@viewlet_config(name='add-pictogram-paragraph.menu', context=IParagraphContainerTarget,
+                view=IParagraphContainerView, layer=IPyAMSLayer, manager=IToolbarAddingMenu,
+                weight=600)
 class PictogramParagraphAddMenu(BaseParagraphAddMenu):
     """Pictogram paragraph add menu"""
 
@@ -80,10 +84,10 @@
     paragraph_type = PICTOGRAM_PARAGRAPH_TYPE
 
 
-@pagelet_config(name='add-pictogram-paragraph.html', context=IParagraphContainerTarget, layer=IPyAMSLayer,
-                permission=MANAGE_CONTENT_PERMISSION)
-@ajax_config(name='add-pictogram-paragraph.json', context=IParagraphContainerTarget, layer=IPyAMSLayer,
-             base=BaseParagraphAJAXAddForm)
+@pagelet_config(name='add-pictogram-paragraph.html', context=IParagraphContainerTarget,
+                layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION)
+@ajax_config(name='add-pictogram-paragraph.json', context=IParagraphContainerTarget,
+             layer=IPyAMSLayer, base=BaseParagraphAJAXAddForm)
 class PictogramParagraphAddForm(BaseParagraphAddForm):
     """Pictogram paragraph add form"""
 
@@ -115,7 +119,8 @@
         updated = changes.get(IPictogramParagraph, ())
         if 'renderer' in updated:
             output.setdefault('events', []).append(
-                get_json_widget_refresh_event(self.context, self.request, PictogramParagraphInnerEditForm, 'renderer'))
+                get_json_widget_refresh_event(self.context, self.request,
+                                              PictogramParagraphInnerEditForm, 'renderer'))
         return output
 
 
@@ -180,7 +185,8 @@
         return list(super(PictogramsTable, self).values)
 
 
-@adapter_config(context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable), provides=IValues)
+@adapter_config(context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable),
+                provides=IValues)
 class PictogramsTableValuesAdapter(ContextRequestViewAdapter):
     """Pictograms table values adapter"""
 
@@ -189,13 +195,16 @@
         return IPictogramContainer(self.context).values()
 
 
-@adapter_config(name='sorter', context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable), provides=IColumn)
+@adapter_config(name='sorter',
+                context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable),
+                provides=IColumn)
 class PictogramsTableSorterColumn(ProtectedFormObjectMixin, SorterColumn):
     """Pictograms table sorter column"""
 
 
-@view_config(name='set-pictograms-order.json', context=IPictogramContainer, request_type=IPyAMSLayer,
-             permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
+@view_config(name='set-pictograms-order.json', context=IPictogramContainer,
+             request_type=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION,
+             renderer='json', xhr=True)
 def set_pictograms_order(request):
     """Update pictograms order"""
     order = list(map(str, json.loads(request.params.get('names'))))
@@ -203,20 +212,24 @@
     return {'status': 'success'}
 
 
-@adapter_config(name='show-hide', context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable),
+@adapter_config(name='show-hide',
+                context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable),
                 provides=IColumn)
 class PictogramsTableShowHideColumn(ProtectedFormObjectMixin, VisibilitySwitcherColumn):
     """Pictograms container visibility switcher column"""
 
 
-@view_config(name='switch-pictogram-visibility.json', context=IPictogramContainer, request_type=IPyAMSLayer,
-             permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
+@view_config(name='switch-pictogram-visibility.json', context=IPictogramContainer,
+             request_type=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION,
+             renderer='json', xhr=True)
 def switch_pictogram_visibility(request):
     """Set pictogram visibility"""
     return switch_element_visibility(request, IPictogramContainer)
 
 
-@adapter_config(name='image', context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable), provides=IColumn)
+@adapter_config(name='image',
+                context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable),
+                provides=IColumn)
 class PictogramsTableImageColumn(GetAttrColumn):
     """Pictogram image column"""
 
@@ -235,7 +248,9 @@
         return '--'
 
 
-@adapter_config(name='name', context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable), provides=IColumn)
+@adapter_config(name='name',
+                context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable),
+                provides=IColumn)
 class PictogramsTableNameColumn(I18nColumn, I18nAttrColumn):
     """Pictograms table name column"""
 
@@ -252,7 +267,9 @@
         return value or BaseParagraph.empty_title
 
 
-@adapter_config(name='body', context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable), provides=IColumn)
+@adapter_config(name='body',
+                context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable),
+                provides=IColumn)
 class PictogramsTableBodyColumn(I18nColumn, I18nAttrColumn):
     """Pictograms table body column"""
 
@@ -267,12 +284,15 @@
         return get_text_start(value, 80, 10)
 
 
-@adapter_config(name='trash', context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable), provides=IColumn)
+@adapter_config(name='trash',
+                context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable),
+                provides=IColumn)
 class PictogramsTableTrashColumn(ProtectedFormObjectMixin, TrashColumn):
     """Pictograms table trash column"""
 
 
-@adapter_config(name='pictograms', context=(IPictogramContainerTarget, IPyAMSLayer, IPictogramsParentForm),
+@adapter_config(name='pictograms',
+                context=(IPictogramContainerTarget, IPyAMSLayer, IPictogramsParentForm),
                 provides=IInnerSubForm)
 @implementer(IPictogramsView)
 class PictogramsView(InnerTableView):
@@ -288,8 +308,9 @@
 # Pictograms forms
 #
 
-@viewlet_config(name='add-pictogram.action', context=IPictogramContainerTarget, layer=IPyAMSLayer, view=IPictogramsView,
-                manager=IWidgetTitleViewletManager, permission=MANAGE_CONTENT_PERMISSION, weight=1)
+@viewlet_config(name='add-pictogram.action', context=IPictogramContainerTarget,
+                layer=IPyAMSLayer, view=IPictogramsView, manager=IWidgetTitleViewletManager,
+                permission=MANAGE_CONTENT_PERMISSION, weight=1)
 class PictogramAddAction(ToolbarAction):
     """Pictogram add action"""
 
@@ -329,7 +350,8 @@
         return {
             'status': 'success',
             'message': self.request.localizer.translate(_("Pictogram was correctly added")),
-            'events': [get_json_switched_table_refresh_event(self.context, self.request, PictogramsTable), ]
+            'events': [get_json_switched_table_refresh_event(self.context, self.request,
+                                                             PictogramsTable), ]
         }
 
 
@@ -341,7 +363,8 @@
         event.form.widgets.errors += (Invalid(_("You must select a pictogram!")), )
 
 
-@pagelet_config(name='properties.html', context=IPictogramItem, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION)
+@pagelet_config(name='properties.html', context=IPictogramItem, layer=IPyAMSLayer,
+                permission=MANAGE_CONTENT_PERMISSION)
 @ajax_config(name='properties.json', context=IPictogramItem, layer=IPyAMSLayer)
 class PictogramPropertiesEditForm(AdminDialogEditForm):
     """Pictogram properties edit form"""
@@ -367,7 +390,8 @@
         if updated:
             target = get_parent(self.context, IPictogramContainerTarget)
             output.setdefault('events', []).append(
-                get_json_table_row_refresh_event(target, self.request, PictogramsTable, self.context))
+                get_json_table_row_refresh_event(target, self.request,
+                                                 PictogramsTable, self.context))
         return output
 
 
--- a/src/pyams_content/reference/pictograms/zmi/__init__.py	Mon Jul 20 14:08:32 2020 +0200
+++ b/src/pyams_content/reference/pictograms/zmi/__init__.py	Mon Jul 20 15:07:41 2020 +0200
@@ -10,42 +10,41 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
-__docformat__ = 'restructuredtext'
-
-
-# import standard library
 from uuid import uuid4
 
-# import interfaces
-from pyams_content.interfaces import MANAGE_SITE_ROOT_PERMISSION, IBaseContent
-from pyams_content.reference.pictograms.interfaces import IPictogramTable, IPictogram
-from pyams_content.reference.zmi.table import ReferenceTableContentsTable, ReferenceTableContentsView
-from pyams_i18n.interfaces import II18n
-from pyams_skin.interfaces.viewlet import IWidgetTitleViewletManager
-from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-from pyams_zmi.layer import IAdminLayer
-from z3c.table.interfaces import IColumn
-
-# import packages
-from pyams_content.reference.pictograms import Pictogram
-from pyams_file.zmi.image import render_image
-from pyams_form.form import AJAXAddForm, ajax_config
-from pyams_i18n.column import I18nAttrColumn
-from pyams_pagelet.pagelet import pagelet_config
-from pyams_skin.event import get_json_table_row_refresh_event
-from pyams_skin.table import I18nColumn
-from pyams_skin.viewlet.toolbar import ToolbarAction
-from pyams_utils.adapter import adapter_config
-from pyams_utils.traversing import get_parent
-from pyams_viewlet.viewlet import viewlet_config
-from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
 from pyramid.httpexceptions import HTTPNotFound
 from pyramid.renderers import render, render_to_response
 from pyramid.response import Response
 from pyramid.view import view_config
 from z3c.form import field
 from z3c.table.column import GetAttrColumn
+from z3c.table.interfaces import IColumn
+
+from pyams_content.interfaces import IBaseContent, MANAGE_SITE_ROOT_PERMISSION
+from pyams_content.reference.pictograms import Pictogram
+from pyams_content.reference.pictograms.interfaces import IPictogram, IPictogramTable
+from pyams_content.reference.zmi.table import ReferenceTableContentsTable, \
+    ReferenceTableContentsView
+from pyams_file.image import render_image
+from pyams_form.form import AJAXAddForm, ajax_config
+from pyams_i18n.column import I18nAttrColumn
+from pyams_i18n.interfaces import II18n
+from pyams_pagelet.pagelet import pagelet_config
+from pyams_skin.event import get_json_table_row_refresh_event
+from pyams_skin.interfaces.viewlet import IWidgetTitleViewletManager
+from pyams_skin.layer import IPyAMSLayer
+from pyams_skin.table import I18nColumn
+from pyams_skin.viewlet.toolbar import ToolbarAction
+from pyams_utils.adapter import adapter_config
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
+from pyams_utils.traversing import get_parent
+from pyams_viewlet.viewlet import viewlet_config
+from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
+from pyams_zmi.layer import IAdminLayer
+
+
+__docformat__ = 'restructuredtext'
+
 
 from pyams_content import _
 
@@ -64,7 +63,8 @@
 
 @pagelet_config(name='add-pictogram.html', context=IPictogramTable, layer=IPyAMSLayer,
                 permission=MANAGE_SITE_ROOT_PERMISSION)
-@ajax_config(name='add-pictogram.json', context=IPictogramTable, layer=IPyAMSLayer, base=AJAXAddForm)
+@ajax_config(name='add-pictogram.json', context=IPictogramTable, layer=IPyAMSLayer,
+             base=AJAXAddForm)
 class PictogramAddForm(AdminDialogAddForm):
     """Pictogram add form"""
 
@@ -85,7 +85,8 @@
         return 'contents.html'
 
 
-@pagelet_config(name='properties.html', context=IPictogram, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
+@pagelet_config(name='properties.html', context=IPictogram, layer=IPyAMSLayer,
+                permission=VIEW_SYSTEM_PERMISSION)
 @ajax_config(name='properties.json', context=IPictogram, layer=IPyAMSLayer)
 class PictogramEditForm(AdminDialogEditForm):
     """Pictogram properties edit form"""
@@ -104,7 +105,8 @@
            ('title' in changes.get(IBaseContent, ())):
             parent = get_parent(self.context, IPictogramTable)
             output.setdefault('events', []).append(
-                get_json_table_row_refresh_event(parent, self.request, PictogramTableContentsTable, self.context))
+                get_json_table_row_refresh_event(parent, self.request,
+                                                 PictogramTableContentsTable, self.context))
         return output
 
 
@@ -126,7 +128,9 @@
         return attributes
 
 
-@adapter_config(name='image', context=(IPictogramTable, IAdminLayer, PictogramTableContentsTable), provides=IColumn)
+@adapter_config(name='image',
+                context=(IPictogramTable, IAdminLayer, PictogramTableContentsTable),
+                provides=IColumn)
 class PictogramTableImageColumn(GetAttrColumn):
     """Pictogram table image column"""
 
@@ -143,7 +147,9 @@
         return '--'
 
 
-@adapter_config(name='name', context=(IPictogramTable, IAdminLayer, PictogramTableContentsTable), provides=IColumn)
+@adapter_config(name='name',
+                context=(IPictogramTable, IAdminLayer, PictogramTableContentsTable),
+                provides=IColumn)
 class PictogramTableNameColumn(I18nColumn, I18nAttrColumn):
     """Pictogram table name column"""
 
@@ -152,7 +158,8 @@
     attrName = 'title'
 
 
-@pagelet_config(name='contents.html', context=IPictogramTable, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
+@pagelet_config(name='contents.html', context=IPictogramTable, layer=IPyAMSLayer,
+                permission=VIEW_SYSTEM_PERMISSION)
 class PictogramTableContentsView(ReferenceTableContentsView):
     """Pictograms table contents view"""