Skip to content

Commit

Permalink
[fc] Repository: plone.autoform
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2017-05-17T12:07:23+02:00
Author: Jens W. Klein (jensens) <[email protected]>
Commit: plone/plone.autoform@cabd75f

Reduce field move failure logging from error to warning

Files changed:
M CHANGES.rst
M plone/autoform/base.py
Repository: plone.autoform
Branch: refs/heads/master
Date: 2017-05-17T12:19:28+02:00
Author: Robert Niederreiter (rnixx) <[email protected]>
Commit: plone/plone.autoform@84494fd

Merge pull request #27 from plone/jensens-fieldmovelogging

Reduce field move failure logging from error to warning

Files changed:
M CHANGES.rst
M plone/autoform/base.py
  • Loading branch information
rnixx committed May 17, 2017
1 parent d94d0fa commit 07e8146
Showing 1 changed file with 97 additions and 255 deletions.
352 changes: 97 additions & 255 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,290 +1,132 @@
Repository: plone.locking
Repository: plone.autoform


Branch: refs/heads/master
Date: 2017-05-16T21:30:16+02:00
Author: ale-rt (ale-rt) <[email protected]>
Commit: https://github.com/plone/plone.locking/commit/ef0ed707b46ee74ed3e8a021b925b0425cdfa814
Date: 2017-05-17T12:07:23+02:00
Author: Jens W. Klein (jensens) <[email protected]>
Commit: https://github.com/plone/plone.autoform/commit/cabd75ff2ba1185b953180b2694f8870e3a07832

All LockingOperations method can optionally redirect to the context view
Reduce field move failure logging from error to warning

Files changed:
M CHANGES.rst
M plone/locking/browser/locking.py
M setup.py
M plone/autoform/base.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 9025a79..325f456 100644
index 99c79ca..eb0e37f 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,7 +1,7 @@
Changelog
=========

-2.1.4 (unreleased)
+2.2.0 (unreleased)
------------------

Breaking changes:
@@ -10,7 +10,8 @@ Breaking changes:

New features:

-- *add item here*
+- All LockingOperations method can optionally redirect to the context view
+ [ale-rt]
@@ -14,6 +14,10 @@ New features:

Bug fixes:

diff --git a/plone/locking/browser/locking.py b/plone/locking/browser/locking.py
index 4832f36..cbfa0c4 100644
--- a/plone/locking/browser/locking.py
+++ b/plone/locking/browser/locking.py
@@ -1,16 +1,16 @@
-
+# -*- coding: utf-8 -*-
from Acquisition import aq_inner
-from zope.component import getUtility
-from Products.Five import BrowserView
-from Products.CMFCore.utils import getToolByName
-
from DateTime import DateTime
from datetime import timedelta
-
-from plone.locking.interfaces import ILockable, IRefreshableLockable
+from plone.locking.interfaces import ILockable
+from plone.locking.interfaces import IRefreshableLockable
from plone.registry.interfaces import IRegistry
+from Products.CMFCore.utils import getToolByName
+from Products.Five import BrowserView
+from zope.component import getUtility
from zope.i18nmessageid import MessageFactory

+
_ = MessageFactory('plone')


@@ -18,6 +18,17 @@ class LockingOperations(BrowserView):
"""Lock acquisition and stealing operations
"""

+ def redirect(self):
+ """Redirect to the context view if needed
+ """
+ url = self.context.absolute_url()
+ registry = getUtility(IRegistry)
+ types_use_view = registry.get(
+ 'plone.types_use_view_action_in_listings', [])
+ if self.context.portal_type in types_use_view:
+ url += '/view'
+ self.request.RESPONSE.redirect(url)
+- Reduce field move failure logging from error to warning.
+ Log more information like full rule.
+ [jensens]
+
def force_unlock(self, redirect=True):
"""Steal the lock.

@@ -27,35 +38,34 @@ def force_unlock(self, redirect=True):
lockable = ILockable(self.context)
lockable.unlock()
if redirect:
- url = self.context.absolute_url()
- registry = getUtility(IRegistry)
- types_use_view = registry.get(
- 'plone.types_use_view_action_in_listings', [])
- if self.context.portal_type in types_use_view:
- url += '/view'
+ self.redirect()

- self.request.RESPONSE.redirect(url)
-
- def create_lock(self):
+ def create_lock(self, redirect=True):
"""Lock the object if it is unlocked
"""
lockable = IRefreshableLockable(self.context, None)
if lockable is not None:
lockable.lock()
+ if redirect:
+ self.redirect()

- def safe_unlock(self):
+ def safe_unlock(self, redirect=True):
"""Unlock the object if the current user has the lock
"""
lockable = ILockable(self.context)
if lockable.can_safely_unlock():
lockable.unlock()
+ if redirect:
+ self.redirect()

- def refresh_lock(self):
+ def refresh_lock(self, redirect=True):
"""Reset the lock start time
"""
lockable = IRefreshableLockable(self.context, None)
if lockable is not None:
lockable.refresh_lock()
+ if redirect:
+ self.redirect()


class LockingInformation(BrowserView):
diff --git a/setup.py b/setup.py
index 72b7f7b..5a56623 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

-version = '2.1.4.dev0'
+version = '2.2.0.dev0'

setup(name='plone.locking',
version=version,
- Fix traceback in updateFieldsFromSchemata for forms with no schema.
[davisagli]

diff --git a/plone/autoform/base.py b/plone/autoform/base.py
index e20ba54..7addd53 100644
--- a/plone/autoform/base.py
+++ b/plone/autoform/base.py
@@ -241,15 +241,21 @@ def _process_field_moves(self, rules):
)
try:
move(self, name, before=before, after=after, prefix=prefix)
- except KeyError:
- # The relative_to field doesn't exist
- logger.exception(
- 'No field move possible for non-existing field named '
- '{0} with target {1}'.format(
- prefix + '.' + name,
- before or after
+ except KeyError as e:
+ if (
+ e.message.startswith('Field ') and
+ e.message.endswith(' not found')
+ ):
+ # The relative_to field doesn't exist
+ logger.warning(
+ 'Field move to non-existing: '
+ 'field name: {0}, rule: {1}'.format(
+ prefix + '.' + name,
+ str(rule)
+ )
)
- )
+ else:
+ raise
self._process_field_moves(rule.get('with', {}))

def _process_group_order(self):


Repository: plone.locking
Repository: plone.autoform


Branch: refs/heads/master
Date: 2017-05-17T00:22:58+02:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: https://github.com/plone/plone.locking/commit/7f8076e4b97c68e2ec79c16c10abbbcd748dee68
Date: 2017-05-17T12:19:28+02:00
Author: Robert Niederreiter (rnixx) <office@squarewave.at>
Commit: https://github.com/plone/plone.autoform/commit/84494fd0772107dd3c43474479479e4c61faf659

Merge pull request #14 from plone/allow-all-methods-to-redirect
Merge pull request #27 from plone/jensens-fieldmovelogging

All LockingOperations method can optionally redirect to the context view
Reduce field move failure logging from error to warning

Files changed:
M CHANGES.rst
M plone/locking/browser/locking.py
M setup.py
M plone/autoform/base.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 9025a79..325f456 100644
index 99c79ca..eb0e37f 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,7 +1,7 @@
Changelog
=========

-2.1.4 (unreleased)
+2.2.0 (unreleased)
------------------

Breaking changes:
@@ -10,7 +10,8 @@ Breaking changes:

New features:

-- *add item here*
+- All LockingOperations method can optionally redirect to the context view
+ [ale-rt]
@@ -14,6 +14,10 @@ New features:

Bug fixes:

diff --git a/plone/locking/browser/locking.py b/plone/locking/browser/locking.py
index 4832f36..cbfa0c4 100644
--- a/plone/locking/browser/locking.py
+++ b/plone/locking/browser/locking.py
@@ -1,16 +1,16 @@
-
+# -*- coding: utf-8 -*-
from Acquisition import aq_inner
-from zope.component import getUtility
-from Products.Five import BrowserView
-from Products.CMFCore.utils import getToolByName
-
from DateTime import DateTime
from datetime import timedelta
-
-from plone.locking.interfaces import ILockable, IRefreshableLockable
+from plone.locking.interfaces import ILockable
+from plone.locking.interfaces import IRefreshableLockable
from plone.registry.interfaces import IRegistry
+from Products.CMFCore.utils import getToolByName
+from Products.Five import BrowserView
+from zope.component import getUtility
from zope.i18nmessageid import MessageFactory

+
_ = MessageFactory('plone')


@@ -18,6 +18,17 @@ class LockingOperations(BrowserView):
"""Lock acquisition and stealing operations
"""

+ def redirect(self):
+ """Redirect to the context view if needed
+ """
+ url = self.context.absolute_url()
+ registry = getUtility(IRegistry)
+ types_use_view = registry.get(
+ 'plone.types_use_view_action_in_listings', [])
+ if self.context.portal_type in types_use_view:
+ url += '/view'
+ self.request.RESPONSE.redirect(url)
+- Reduce field move failure logging from error to warning.
+ Log more information like full rule.
+ [jensens]
+
def force_unlock(self, redirect=True):
"""Steal the lock.

@@ -27,35 +38,34 @@ def force_unlock(self, redirect=True):
lockable = ILockable(self.context)
lockable.unlock()
if redirect:
- url = self.context.absolute_url()
- registry = getUtility(IRegistry)
- types_use_view = registry.get(
- 'plone.types_use_view_action_in_listings', [])
- if self.context.portal_type in types_use_view:
- url += '/view'
+ self.redirect()

- self.request.RESPONSE.redirect(url)
-
- def create_lock(self):
+ def create_lock(self, redirect=True):
"""Lock the object if it is unlocked
"""
lockable = IRefreshableLockable(self.context, None)
if lockable is not None:
lockable.lock()
+ if redirect:
+ self.redirect()

- def safe_unlock(self):
+ def safe_unlock(self, redirect=True):
"""Unlock the object if the current user has the lock
"""
lockable = ILockable(self.context)
if lockable.can_safely_unlock():
lockable.unlock()
+ if redirect:
+ self.redirect()

- def refresh_lock(self):
+ def refresh_lock(self, redirect=True):
"""Reset the lock start time
"""
lockable = IRefreshableLockable(self.context, None)
if lockable is not None:
lockable.refresh_lock()
+ if redirect:
+ self.redirect()


class LockingInformation(BrowserView):
diff --git a/setup.py b/setup.py
index 72b7f7b..5a56623 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

-version = '2.1.4.dev0'
+version = '2.2.0.dev0'

setup(name='plone.locking',
version=version,
- Fix traceback in updateFieldsFromSchemata for forms with no schema.
[davisagli]

diff --git a/plone/autoform/base.py b/plone/autoform/base.py
index e20ba54..7addd53 100644
--- a/plone/autoform/base.py
+++ b/plone/autoform/base.py
@@ -241,15 +241,21 @@ def _process_field_moves(self, rules):
)
try:
move(self, name, before=before, after=after, prefix=prefix)
- except KeyError:
- # The relative_to field doesn't exist
- logger.exception(
- 'No field move possible for non-existing field named '
- '{0} with target {1}'.format(
- prefix + '.' + name,
- before or after
+ except KeyError as e:
+ if (
+ e.message.startswith('Field ') and
+ e.message.endswith(' not found')
+ ):
+ # The relative_to field doesn't exist
+ logger.warning(
+ 'Field move to non-existing: '
+ 'field name: {0}, rule: {1}'.format(
+ prefix + '.' + name,
+ str(rule)
+ )
)
- )
+ else:
+ raise
self._process_field_moves(rule.get('with', {}))

def _process_group_order(self):


0 comments on commit 07e8146

Please sign in to comment.