[CMF-checkins] CVS: CMF/CMFDefault/skins/zpt_control -
folder_bottom.py:1.1 folder_copy.py:1.1 folder_cut.py:1.1
folder_delete.py:1.1 folder_down.py:1.1 folder_paste.py:1.1
folder_rename.py:1.1 folder_sort.py:1.1 folder_top.py:1.1
folder_up.py:1.1 setRedirect.py:1.1 setStatus.py:1.1
validateItemIds.py:1.1
Yvo Schubbe
y.2004_ at wcm-solutions.de
Tue Jun 1 12:53:09 EDT 2004
Update of /cvs-repository/CMF/CMFDefault/skins/zpt_control
In directory cvs.zope.org:/tmp/cvs-serv2948/CMFDefault/skins/zpt_control
Added Files:
folder_bottom.py folder_copy.py folder_cut.py folder_delete.py
folder_down.py folder_paste.py folder_rename.py folder_sort.py
folder_top.py folder_up.py setRedirect.py setStatus.py
validateItemIds.py
Log Message:
- factored out (again) the controllers for folder_contents / folder_rename_form
- added validateItemIds to check if any items were selected
- added the two helper methods setStatus and setRedirect
=== Added File CMF/CMFDefault/skins/zpt_control/folder_bottom.py ===
## Script (Python) "folder_bottom"
##parameters=ids, **kw
##title=
##
subset_ids = [ obj.getId() for obj in context.listFolderContents() ]
try:
try:
attempt = context.moveObjectsToBottom(ids, subset_ids=subset_ids)
except TypeError:
# Zope 2.7.0
attempt = context.moveObjectsToBottom(ids)
if attempt:
return context.setStatus( True, '%d item%s moved to bottom.' %
( attempt, (attempt != 1 and 's' or '') ) )
else:
return context.setStatus(False, 'Nothing to change.')
except ValueError, errmsg:
return context.setStatus(False, 'ValueError: %s' % errmsg)
=== Added File CMF/CMFDefault/skins/zpt_control/folder_copy.py ===
## Script (Python) "folder_copy"
##parameters=ids, **kw
##title=Copy objects from a folder to the clipboard
##
context.manage_copyObjects(ids, context.REQUEST)
return context.setStatus( True, 'Item%s copied.' %
( len(ids) != 1 and 's' or '' ) )
=== Added File CMF/CMFDefault/skins/zpt_control/folder_cut.py ===
## Script (Python) "folder_cut"
##parameters=ids, **kw
##title=Cut objects from a folder and copy to the clipboard
##
context.manage_cutObjects(ids, context.REQUEST)
return context.setStatus( True, 'Item%s cut.' %
( len(ids) != 1 and 's' or '' ) )
=== Added File CMF/CMFDefault/skins/zpt_control/folder_delete.py ===
## Script (Python) "folder_delete"
##parameters=ids, **kw
##title=Delete objects from a folder
##
context.manage_delObjects( list(ids) )
return context.setStatus( True, 'Item%s deleted.' %
( len(ids) != 1 and 's' or '' ) )
=== Added File CMF/CMFDefault/skins/zpt_control/folder_down.py ===
## Script (Python) "folder_down"
##parameters=ids, delta, **kw
##title=
##
subset_ids = [ obj.getId() for obj in context.listFolderContents() ]
try:
try:
attempt = context.moveObjectsDown(ids, delta, subset_ids=subset_ids)
except TypeError:
# Zope 2.7.0
attempt = context.moveObjectsDown(ids, delta)
if attempt:
return context.setStatus( True, '%d item%s moved down.' %
( attempt, (attempt != 1 and 's' or '') ) )
else:
return context.setStatus(False, 'Nothing to change.')
except ValueError, errmsg:
return context.setStatus(False, 'ValueError: %s' % errmsg)
=== Added File CMF/CMFDefault/skins/zpt_control/folder_paste.py ===
## Script (Python) "folder_paste"
##parameters=**kw
##title=Paste objects to a folder from the clipboard
##
from Products.CMFDefault.exceptions import CopyError
from Products.CMFDefault.exceptions import zExceptions_Unauthorized
if context.cb_dataValid:
try:
result = context.manage_pasteObjects(context.REQUEST['__cp'])
return context.setStatus( True, 'Item%s pasted.' %
( len(result) != 1 and 's' or '' ) )
except CopyError:
return context.setStatus(False, 'CopyError: Paste failed.')
except zExceptions_Unauthorized:
return context.setStatus(False, 'Unauthorized: Paste failed.')
else:
return context.setStatus(False, 'Please copy or cut one or more items to'
'paste first.')
=== Added File CMF/CMFDefault/skins/zpt_control/folder_rename.py ===
## Script (Python) "folder_rename"
##parameters=ids, new_ids, **kw
##title=Rename objects in a folder
##
from Products.CMFDefault.exceptions import CopyError
if not ids == new_ids:
try:
context.manage_renameObjects(ids, new_ids)
return context.setStatus(True, 'Item%s renamed.' %
( len(ids) != 1 and 's' or '' ) )
except CopyError:
return context.setStatus(False, 'CopyError: Rename failed.')
else:
return context.setStatus(False, 'Nothing to change.')
=== Added File CMF/CMFDefault/skins/zpt_control/folder_sort.py ===
## Script (Python) "folder_sort"
##parameters=key='position', reverse=0, **kw
##title=Sort objects in a folder
##
context.setDefaultSorting(key, reverse)
return context.setStatus(True)
=== Added File CMF/CMFDefault/skins/zpt_control/folder_top.py ===
## Script (Python) "folder_top"
##parameters=ids, **kw
##title=
##
subset_ids = [ obj.getId() for obj in context.listFolderContents() ]
try:
try:
attempt = context.moveObjectsToTop(ids, subset_ids=subset_ids)
except TypeError:
# Zope 2.7.0
attempt = context.moveObjectsToTop(ids)
if attempt:
return context.setStatus( True, '%d item%s moved to top.' %
( attempt, (attempt != 1 and 's' or '') ) )
else:
return context.setStatus(False, 'Nothing to change.')
except ValueError, errmsg:
return context.setStatus(False, 'ValueError: %s' % errmsg)
=== Added File CMF/CMFDefault/skins/zpt_control/folder_up.py ===
## Script (Python) "folder_up"
##parameters=ids, delta, **kw
##title=
##
subset_ids = [ obj.getId() for obj in context.listFolderContents() ]
try:
try:
attempt = context.moveObjectsUp(ids, delta, subset_ids=subset_ids)
except TypeError:
# Zope 2.7.0
attempt = context.moveObjectsUp(ids, delta)
if attempt:
return context.setStatus( True, '%d item%s moved up.' %
( attempt, (attempt != 1 and 's' or '') ) )
else:
return context.setStatus(False, 'Nothing to change.')
except ValueError, errmsg:
return context.setStatus(False, 'ValueError: %s' % errmsg)
=== Added File CMF/CMFDefault/skins/zpt_control/setRedirect.py ===
##parameters=provider, action_path, **kw
##
from ZTUtils import make_query
from Products.CMFCore.utils import getToolByName
utool = getToolByName(script, 'portal_url')
portal_url = utool()
try:
target = provider.getActionInfo(action_path)['url']
except ValueError:
target = portal_url
message = context.REQUEST.other.get('portal_status_message', '')
kw['portal_status_message'] = message
for k, v in kw.items():
if not v:
del kw[k]
if kw:
query = make_query(kw)
context.REQUEST.RESPONSE.redirect( '%s?%s' % (target, query) )
else:
context.REQUEST.RESPONSE.redirect(target)
return True
=== Added File CMF/CMFDefault/skins/zpt_control/setStatus.py ===
## Script (Python) "setStatus"
##parameters=success, message='', **kw
##title=
##
if message:
context.REQUEST.other['portal_status_message'] = message
if kw:
for k, v in kw.items():
context.REQUEST.form[k] = v
return success
=== Added File CMF/CMFDefault/skins/zpt_control/validateItemIds.py ===
## Script (Python) "validateItemIds"
##parameters=ids=(), **kw
##title=
##
if ids:
return context.setStatus(True)
else:
return context.setStatus(False, 'Please select one or more items first.')
More information about the CMF-checkins
mailing list