Back to index

plone3  3.1.7
object_rename.py
Go to the documentation of this file.
00001 ## Python Script "object_rename"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=
00008 ##title=Show the rename form for an object
00009 ##
00010 
00011 from Products.CMFPlone.utils import safe_unicode
00012 from Products.CMFPlone.utils import transaction_note
00013 from Products.CMFCore.utils import getToolByName
00014 from OFS.CopySupport import CopyError
00015 from AccessControl import Unauthorized
00016 from Products.PythonScripts.standard import url_quote_plus
00017 
00018 REQUEST = context.REQUEST
00019 title = safe_unicode(context.title_or_id())
00020 
00021 mtool = getToolByName(context, 'portal_membership')
00022 if not mtool.checkPermission('Copy or Move', context):
00023     raise Unauthorized, _(u'Permission denied to rename ${title}.',
00024                           mapping={u'title': title})
00025 
00026 pathName = url_quote_plus('paths:list')
00027 safePath = '/'.join(context.getPhysicalPath())
00028 orig_template = REQUEST['HTTP_REFERER'].split('?')[0]
00029 url = '%s/folder_rename_form?orig_template=%s&%s=%s' % (context.absolute_url(),
00030                                                         orig_template,
00031                                                         pathName, 
00032                                                         safePath)
00033 
00034 REQUEST.RESPONSE.redirect(url)