## Script (Python) "topic_source_locator_edit"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=REQUEST, RESPONSE
##title=
##
from Products.PythonScripts.standard import url_quote

new_source_locator = REQUEST.new_source_locator
locator = REQUEST.get('source_locator', None)

if not locator is None:
    if new_source_locator != locator:
        if context.removeSourceLocator(locator):
            context.addSourceLocator(new_source_locator)
        else:
            RESPONSE.redirect(context.absolute_url() + "/topic_source_locator_edit_form?warning_message=Unable+to+store+locator&source_locator=" + url_quote(locator))
            return

RESPONSE.redirect(context.absolute_url() + "/topic_source_locator_edit_form?source_locator=" + url_quote(new_source_locator))
