Skip to content

Commit

Permalink
Merge pull request #61 from plone/use-check-id-function
Browse files Browse the repository at this point in the history
Use check_id function from CMFPlone.utils. [master/5.2]
  • Loading branch information
mauritsvanrees authored Oct 22, 2018
2 parents 011b9e2 + 086d90e commit 6e28978
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
20 changes: 8 additions & 12 deletions Products/ATContentTypes/content/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from Products.CMFCore.permissions import View
from Products.CMFCore.utils import getToolByName
from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin
from Products.CMFPlone.utils import check_id
from webdav.Lockable import ResourceLockedError
from webdav.NullResource import NullResource
from webdav.Resource import Resource as WebdavResoure
Expand Down Expand Up @@ -382,18 +383,13 @@ def post_validate(self, REQUEST=None, errors=None):
# Set ID in whatever way the base classes usually do.
return

if getattr(self, 'check_id', None) is not None:
check_id = self.check_id(used_id, required=1)
else:
# If check_id is not available just look for conflicting ids
parent = aq_parent(aq_inner(self))
check_id = used_id in parent and \
'Id %s conflicts with an existing item' % used_id or False
if check_id and used_id == id:
errors['id'] = check_id
REQUEST.form['id'] = used_id
elif check_id:
errors[f_name] = check_id
check_id_result = check_id(self, used_id, required=1)
if check_id_result:
if used_id == id:
errors['id'] = check_id_result
REQUEST.form['id'] = used_id
else:
errors[f_name] = check_id_result

@security.private
def manage_afterPUT(self, data, marshall_data, file, context, mimetype,
Expand Down
1 change: 1 addition & 0 deletions news/60.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use new utils.check_id from CMFPlone. [maurits]

0 comments on commit 6e28978

Please sign in to comment.