Products.CMFPlone/plip-1486-redirection: Update redirects.py
Stephan Klinger <jenkins-z4DKO/[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.cvs |
|---|---|
| Message-ID | <[email protected]> |
Repository: Products.CMFPlone Branch: refs/heads/plip-1486-redirection Date: 2017-07-10T09:31:40+03:00 Author: Stephan Klinger (staeff) <[email protected]> Commit: https://github.com/plone/Products.CMFPlone/commit/0b03829c20d9ae36eca98d100849abb0aea606f7 Update redirects.py Files changed: M Products/CMFPlone/controlpanel/browser/redirects.py diff --git a/Products/CMFPlone/controlpanel/browser/redirects.py b/Products/CMFPlone/controlpanel/browser/redirects.py index 77757c6d7..fa7342fd8 100644 --- a/Products/CMFPlone/controlpanel/browser/redirects.py +++ b/Products/CMFPlone/controlpanel/browser/redirects.py @@ -49,12 +49,12 @@ def absolutize_path(path, context=None, is_alias=True): # Check whether obj exists at source path result = api.content.find(path={"query": path}) if len(result) == 0: - err = _(u"The provided target object does exist.") + err = _(u"The provided target object does not exist.") if not err and is_alias: - # Check whether obj exists at target path - result = api.content.find(path={"query": path}) - if len(result) != 0: - err = _(u"The provided already does already exist.") + # Check whether already exists in storage + if storage.get(path): + err = _(u"The provided alias already exists!") + return path, err class RedirectsView(BrowserView): @@ -198,9 +198,12 @@ def __call__(self): def add(self, redirection, target, portal, storage, status): """Add the redirections from the form. If anything goes wrong, do nothing.""" + abs_target = '' + target_err = '' abs_redirection, err = absolutize_path(redirection, is_alias=True) - abs_target, target_err = absolutize_path(target, is_alias=False) + if not err: + abs_target, target_err = absolutize_path(target, is_alias=False) if err and target_err: err = "{0} {1}".format(err, target_err) @@ -212,7 +215,7 @@ def add(self, redirection, target, portal, storage, status): u"an endless cycle of redirects.") # TODO: detect indirect recursion - if not err: + if err: status.addStatusMessage(_(err), type='error') else: storage.add(abs_redirection, abs_target) ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot