Commit da476c61 authored by 's avatar

Added multiple copy, paste, rename

parent ee6c5127
"""Copy interface""" __doc__="""Copy interface"""
__version__='$Revision: 1.18 $'[11:-2]
__version__='$Revision: 1.17 $'[11:-2] import sys, Globals, Moniker, rPickle, tempfile
import Globals, Moniker, rPickle, tempfile
from cPickle import loads, dumps from cPickle import loads, dumps
from urllib import quote, unquote from urllib import quote, unquote
from App.Dialogs import MessageDialog from App.Dialogs import MessageDialog
rPickle.register('OFS.Moniker', 'Moniker', Moniker.Moniker)
CopyError='Copy Error'
class CopyContainer: class CopyContainer:
# Interface for containerish objects which allow # Interface for containerish objects which allow cut/copy/paste
# objects to be copied into them.
def manage_cutObjects(self, ids, REQUEST=None):
"""Put a reference to the objects named in ids in the clip board"""
if type(ids) is type(''):
ids=[ids]
oblist=[]
for id in ids:
ob=getattr(self, id)
if not ob.cb_isMoveable():
raise CopyError, eNotSupported % id
m=Moniker.Moniker(ob)
oblist.append((m.jar, m.ids))
cp=(1, oblist)
cp=quote(dumps(cp))
if REQUEST is not None:
resp=REQUEST['RESPONSE']
resp.setCookie('__cp', cp, path='%s' % REQUEST['SCRIPT_NAME'])
return self.manage_main(self, REQUEST, cb_dataValid=1)
return cp
def manage_copyObjects(self, ids, REQUEST=None, RESPONSE=None):
"""Put a reference to the objects named in ids in the clip board"""
if type(ids) is type(''):
ids=[ids]
oblist=[]
for id in ids:
ob=getattr(self, id)
if not ob.cb_isCopyable():
raise CopyError, eNotSupported % id
m=Moniker.Moniker(ob)
oblist.append((m.jar, m.ids))
cp=(0, oblist)
cp=quote(dumps(cp))
if REQUEST is not None:
resp=REQUEST['RESPONSE']
resp.setCookie('__cp', cp, path='%s' % REQUEST['SCRIPT_NAME'])
return self.manage_main(self, REQUEST, cb_dataValid=1)
return cp
def manage_pasteObjects(self, cb_copy_data=None, REQUEST=None):
"""Paste previously copied objects into the current object.
If calling manage_pasteObjects from python code, pass
the result of a previous call to manage_cutObjects or
manage_copyObjects as the first argument."""
cp=None
if cb_copy_data is not None:
cp=cb_copy_data
else:
if REQUEST and REQUEST.has_key('__cp'):
cp=REQUEST['__cp']
if cp is None:
raise CopyError, eNoData
try: cp=rPickle.loads(unquote(cp))
except: raise CopyError, eInvalid
oblist=[]
m=Moniker.Moniker()
op=cp[0]
for j, d in cp[1]:
m.jar=j
m.ids=d
try: ob=m.bind()
except: raise CopyError, eNotFound
self._verifyObjectPaste(ob, REQUEST)
try: ob._notifyOfCopyTo(self, op=op)
except: raise CopyError, MessageDialog(
title='Copy Error',
message=sys.exc_value,
action ='manage_main')
oblist.append(ob)
if op==0:
# Copy operation
for ob in oblist:
if not ob.cb_isCopyable():
raise CopyError, eNotSupported % absattr(ob.id)
id=_get_id(self, absattr(ob.id))
ob=ob._getCopy(self)
ob._setId(id)
self._setObject(id, ob)
ob=ob.__of__(self)
ob._postCopy(self, op=0)
if REQUEST is not None:
return self.manage_main(self, REQUEST, update_menu=1,
cb_dataValid=1)
if op==1:
# Move operation
for ob in oblist:
id=absattr(ob.id)
if not ob.cb_isMoveable():
raise CopyError, eNotSupported % id
ob.aq_parent._delObject(id)
if hasattr(ob, 'aq_base'):
ob=ob.aq_base
id=_get_id(self, id)
self._setObject(id, ob)
ob=ob.__of__(self)
ob._setId(id)
ob._postCopy(self, op=1)
if REQUEST is not None:
REQUEST['RESPONSE'].setCookie('cp_', 'deleted',
path='%s' % REQUEST['SCRIPT_NAME'],
expires='Wed, 31-Dec-97 23:59:59 GMT')
return self.manage_main(self, REQUEST, update_menu=1,
cb_dataValid=0)
return ''
pasteDialog=Globals.HTMLFile('pasteDialog', globals())
def _getMoniker(self): manage_renameForm=Globals.HTMLFile('renameForm', globals())
# Ask an object to return a moniker for itself.
return Moniker.Moniker(self)
def validClipData(self): def manage_renameObject(self, id, new_id, REQUEST=None):
# Return true if clipboard data is valid. """Rename a particular sub-object"""
try: moniker=rPickle.loads(unquote(self.REQUEST['clip_data'])) try: self._checkId(new_id)
except: raise CopyError, MessageDialog(
title='Invalid Id',
message=sys.exc_value,
action ='manage_main')
ob=getattr(self, id)
if not ob.cb_isMoveable():
raise CopyError, eNotSupported % id
self._verifyObjectPaste(ob, REQUEST)
try: ob._notifyOfCopyTo(self, op=1)
except: raise CopyError, MessageDialog(
title='Rename Error',
message=sys.exc_value,
action ='manage_main')
self._delObject(id)
if hasattr(ob, 'aq_base'):
ob=ob.aq_base
self._setObject(new_id, ob)
ob=ob.__of__(self)
ob._setId(new_id)
ob._postCopy(self, op=1)
if REQUEST is not None:
return self.manage_main(self, REQUEST, update_menu=1)
return None
def manage_clone(self, ob, id, REQUEST=None):
"""Clone an object, creating a new object with the given id."""
if not ob.cb_isCopyable():
raise CopyError, eNotSupported % absattr(ob.id)
try: self._checkId(id)
except: raise CopyError, MessageDialog(
title='Invalid Id',
message=sys.exc_value,
action ='manage_main')
self._verifyObjectPaste(ob, REQUEST)
try: ob._notifyOfCopyTo(self, op=0)
except: raise CopyError, MessageDialog(
title='Rename Error',
message=sys.exc_value,
action ='manage_main')
ob=ob._getCopy(self)
ob._setId(id)
self._setObject(id, ob)
ob=ob.__of__(self)
ob._postCopy(self, op=0)
return ob
def cb_dataValid(self):
# Return true if clipboard data seems valid.
try: data=rPickle.loads(unquote(self.REQUEST['__cp']))
except: return 0 except: return 0
return 1
# Check for old versions of cookie so users dont need to
# restart browser after upgrading - just expire the old def cb_dataItems(self):
# cookie. try: cp=rPickle.loads(unquote(self.REQUEST['__cp']))
if not hasattr(moniker, 'op'): except: return []
self.REQUEST['RESPONSE'].setCookie('clip_data', 'deleted', oblist=[]
path='%s' % self.REQUEST['SCRIPT_NAME'], m=Moniker.Moniker()
expires='Wed, 31-Dec-97 23:59:59 GMT') op=cp[0]
self.REQUEST['validClipData']=0 for j, d in cp[1]:
return 0 m.jar=j
m.ids=d
v=self.REQUEST['validClipData']=moniker.assert() oblist.append(m.bind())
return v return oblist
def _verifyCopySource(self, src, REQUEST): validClipData=cb_dataValid
if not hasattr(src, 'meta_type'): def _verifyObjectPaste(self, ob, REQUEST):
raise 'Invalid copy source', ( if not hasattr(ob, 'meta_type'):
'''You cannot copy this object, because raise CopyError, MessageDialog(
the typ of the source object is unknown.<p> title='Not Supported',
''') message='The object <EM>%s</EM> does not support this ' \
mt=src.meta_type 'operation' % absattr(ob.id),
action='manage_main')
mt=ob.meta_type
if not hasattr(self, 'all_meta_types'): if not hasattr(self, 'all_meta_types'):
raise 'Invalid Copy Destination', ( raise CopyError, MessageDialog(
'''You cannot copy objects to this destination because title='Not Supported',
it is an invalid destination.<p> message='Cannot paste into this object.',
''') action='manage_main')
method_name=None method_name=None
meta_types=self.all_meta_types() meta_types=absattr(self.all_meta_types)
for d in meta_types: for d in meta_types:
if d['name']==mt: if d['name']==mt:
method_name=d['action'] method_name=d['action']
break break
if method_name is not None: if method_name is not None:
if hasattr(self, method_name): if hasattr(self, method_name):
meth=getattr(self, method_name) meth=getattr(self, method_name)
...@@ -68,180 +223,156 @@ class CopyContainer: ...@@ -68,180 +223,156 @@ class CopyContainer:
if (not hasattr(user, 'hasRole') or if (not hasattr(user, 'hasRole') or
not user.hasRole(None, roles)): not user.hasRole(None, roles)):
raise 'Unauthorized', ( raise 'Unauthorized', (
'''You are not authorized to perform this """You are not authorized to perform this
operation.<p> operation."""
''') )
return return
raise CopyError, MessageDialog(
raise 'Invalid copy source', ( title='Not Supported',
'''You cannot copy this object, because message='The object <EM>%s</EM> does not support this ' \
the type of the source object is unrecognized.<p> 'operation' % absattr(ob.id),
''') action='manage_main')
def pasteFromClipboard(self, clip_id='', clip_data='', REQUEST=None):
""" """
if not clip_data: return eNoData
try: moniker=rPickle.loads(unquote(clip_data))
except: return eInvalid
if not clip_id:
return self.pasteDialog(self,REQUEST,bad=0,moniker=(moniker,))
try: self._checkId(clip_id)
except: return self.pasteDialog(self,REQUEST,bad=1,moniker=(moniker,))
return self.manage_paste(moniker, clip_id, REQUEST)
def manage_paste(self, moniker, clip_id, REQUEST=None):
try: obj=moniker.bind()
except: return eNotFound
self._verifyCopySource(obj, REQUEST)
if moniker.op == 0:
# Copy operation
obj=obj._getCopy(self)
obj._setId(clip_id)
self._setObject(clip_id, obj)
obj=obj.__of__(self)
obj._postCopy(self)
if REQUEST is not None:
return self.manage_main(self, REQUEST, update_menu=1)
return ''
if moniker.op==1:
# Move operation
prev_id=Moniker.absattr(obj.id)
# Check for special object!
try: r=obj.aq_parent._reserved_names
except: r=()
if prev_id in r:
raise 'NotSupported', Globals.MessageDialog(
title='Not Supported',
message='This item cannot be cut and pasted',
action ='manage_main')
obj.aq_parent._delObject(prev_id)
if hasattr(obj, 'aq_base'):
obj=obj.aq_base
self._setObject(clip_id, obj)
obj=obj.__of__(self)
obj._setId(clip_id)
obj._postMove(self)
if REQUEST is not None:
# Remove cookie after a move
REQUEST['RESPONSE'].setCookie('clip_data', 'deleted',
path='%s' % REQUEST['SCRIPT_NAME'],
expires='Wed, 31-Dec-97 23:59:59 GMT')
return self.manage_main(self, REQUEST, update_menu=1,
validClipData=0)
return ''
def manage_clone(self, obj, clip_id, REQUEST=None):
"""Clone an object
By creating a new object with a different given id.
"""
self._verifyCopySource(obj, REQUEST)
obj=obj._getCopy(self)
obj._setId(clip_id)
self._setObject(clip_id, obj)
obj=obj.__of__(self)
obj._postCopy(self)
return obj
Globals.default__class_init__(CopyContainer) Globals.default__class_init__(CopyContainer)
class CopySource: class CopySource:
# Interface for objects which allow themselves to be copied. # Interface for objects which allow themselves to be copied.
def _getMoniker(self): def _canCopy(self, op=0):
# Ask an object to return a moniker for itself. # Called to make sure this object is copyable. The op var
return Moniker.Moniker(self) # is 0 for a copy, 1 for a move.
return 1
def _notifyOfCopyTo(self, container):
# Overide this to be pickly about where you go! def _notifyOfCopyTo(self, container, op=0):
# If you don't want to go there, then raise an exception. # Overide this to be pickly about where you go! If you dont
# want to go there, raise an exception. The op variable is
# 0 for a copy, 1 for a move.
pass pass
def _getCopy(self, container): def _getCopy(self, container):
# Ask an object for a new copy of itself. # Ask an object for a new copy of itself.
self._notifyOfCopyTo(container)
f=tempfile.TemporaryFile() f=tempfile.TemporaryFile()
self._p_jar.export_file(self,f) self._p_jar.export_file(self,f)
f.seek(0) f.seek(0)
r=container._p_jar.import_file(f) ob=container._p_jar.import_file(f)
f.close() f.close()
return r return ob
def _postCopy(self, container): def _postCopy(self, container, op=0):
# Called after the copy is finished to accomodate special cases # Called after the copy is finished to accomodate special cases.
# The op var is 0 for a copy, 1 for a move.
pass pass
def _postMove(self, container):
# Called after a move is finished to accomodate special cases
pass
def _setId(self, id): def _setId(self, id):
# Called to set the new id of a copied object. # Called to set the new id of a copied object.
self.id=id self.id=id
def copyToClipboard(self, REQUEST): def cb_isCopyable(self):
""" """ if not (hasattr(self, '_canCopy') and self._canCopy(0)):
# Set a cookie containing pickled moniker return 0
try: m=self._getMoniker() if hasattr(self, '_p_jar') and self._p_jar is None:
except: return eNotSupported return 0
m.op=0 return 1
REQUEST['RESPONSE'].setCookie('clip_data',
quote(dumps(m, 1)), def cb_isMoveable(self):
path='%s' % REQUEST['SCRIPT_NAME']) if not (hasattr(self, '_canCopy') and self._canCopy(1)):
return 0
def cutToClipboard(self, REQUEST): if hasattr(self, '_p_jar') and self._p_jar is None:
""" """ return 0
# Set a cookie containing pickled moniker try: n=self.aq_parent._reserved_names
try: m=self._getMoniker() except: n=()
except: return eNotSupported if absattr(self.id) in n:
m.op=1 return 0
REQUEST['RESPONSE'].setCookie('clip_data', return 1
quote(dumps(m, 1)),
path='%s' % REQUEST['SCRIPT_NAME'])
def absattr(attr):
if callable(attr): return attr()
return attr
def _get_id(ob, id):
# Predefined errors try: ob=ob.aq_base
except: pass
eNoData=Globals.MessageDialog( n=0
if id[8:]=='copy_of_':
n=1
while (hasattr(ob, id)):
id='copy%s_of_%s' % (n and n+1 or '', id)
n=n+1
return id
fMessageDialog=Globals.HTML("""
<HTML>
<HEAD>
<TITLE><!--#var title--></TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<FORM ACTION="<!--#var action-->" METHOD="GET"
<!--#if target-->
TARGET="<!--#var target-->"
<!--#/if target-->>
<TABLE BORDER="0" WIDTH="100%%" CELLPADDING="10">
<TR>
<TD VALIGN="TOP">
<BR>
<CENTER><B><FONT SIZE="+6" COLOR="#77003B">!</FONT></B></CENTER>
</TD>
<TD VALIGN="TOP">
<BR><BR>
<CENTER>
<!--#var message-->
</CENTER>
</TD>
</TR>
<TR>
<TD VALIGN="TOP">
</TD>
<TD VALIGN="TOP">
<CENTER>
<INPUT TYPE="SUBMIT" VALUE=" Ok ">
</CENTER>
</TD>
</TR>
</TABLE>
</FORM>
</BODY></HTML>""", target='', action='manage_main', title='Changed')
eNoData=MessageDialog(
title='No Data', title='No Data',
message='No clipboard data to be pasted', message='No clipboard data found.',
action ='./manage_main',) action ='manage_main',)
eInvalid=Globals.MessageDialog( eInvalid=MessageDialog(
title='Clipboard Error', title='Clipboard Error',
message='Clipboard data could not be read ' \ message='The data in the clipboard could not be read, possibly due ' \
'or is not supported in this installation', 'to cookie data being truncated by your web browser. Try copying ' \
action ='./manage_main',) 'fewer objects.',
action ='manage_main',)
eNotFound=MessageDialog(
title='Item Not Found',
message='One or more items referred to in the clipboard data was ' \
'not found. The item may have been moved or deleted after you ' \
'copied it.',
action ='manage_main',)
eNotSupported=fMessageDialog(
title='Not Supported',
message='The item <EM>%s</EM> does not support this operation.',
action ='manage_main',)
eNotFound=Globals.MessageDialog(
title='Clipboard Error',
message='The item referenced by the ' \
'clipboard data was not found',
action ='./manage_main',)
eNotSupported=Globals.MessageDialog(
title='Not Supported',
message='Operation not supported for the selected item',
action ='./manage_main',)
##############################################################################
#
# $Log: CopySupport.py,v $
# Revision 1.18 1998/08/14 16:46:35 brian
# Added multiple copy, paste, rename
#
"""Folder object """Folder object
$Id: Folder.py,v 1.50 1998/08/05 21:04:04 brian Exp $""" $Id: Folder.py,v 1.51 1998/08/14 16:46:35 brian Exp $"""
__version__='$Revision: 1.50 $'[11:-2] __version__='$Revision: 1.51 $'[11:-2]
from Globals import HTMLFile from Globals import HTMLFile
...@@ -71,7 +71,8 @@ class Folder(ObjectManager,RoleManager,DocumentHandler, ...@@ -71,7 +71,8 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
('View management screens', ('View management screens',
('manage','manage_menu','manage_main','manage_copyright', ('manage','manage_menu','manage_main','manage_copyright',
'manage_tabs','manage_propertiesForm','manage_UndoForm', 'manage_tabs','manage_propertiesForm','manage_UndoForm',
'manage_copyObject', 'manage_pasteObject', 'manage_cutObjects', 'manage_copyObjects', 'manage_pasteObjects',
'manage_renameForm', 'manage_renameObject',
'manage_findFrame', 'manage_findForm', 'manage_findAdv', 'manage_findFrame', 'manage_findForm', 'manage_findAdv',
'manage_findResult', 'manage_findOpt')), 'manage_findResult', 'manage_findOpt')),
('Access contents information', ('Access contents information',
......
""" """Object monikers
Object monikers
An object moniker is an intelligent reference to a An object moniker is an intelligent reference to a
persistent object. A moniker can be turned back into persistent object. A moniker can be turned back into
...@@ -7,30 +6,25 @@ Object monikers ...@@ -7,30 +6,25 @@ Object monikers
and aquisition relationships via a simple interface. and aquisition relationships via a simple interface.
""" """
__version__='$Revision: 1.5 $'[11:-2]
__version__='$Revision: 1.4 $'[11:-2]
import Globals import Globals
class Moniker: class Moniker:
""" """ """ """
def __init__(self, obj=None, op=0): def __init__(self, ob=None):
if obj is None: return if ob is None: return
pd=[] self.jar=ob._p_jar.name
ob=obj self.ids=[]
while 1: while 1:
if not hasattr(ob, '_p_oid'): if not hasattr(ob, '_p_oid'):
break break
pd.append(ob._p_oid) self.ids.append(ob._p_oid)
if not hasattr(ob, 'aq_parent'): if not hasattr(ob, 'aq_parent'):
break break
ob=ob.aq_parent ob=ob.aq_parent
pd.reverse() self.ids.reverse()
self.pd=pd
self.jr=obj._p_jar.name
self.op=op
def id(self): def id(self):
return absattr(self.bind().id) return absattr(self.bind().id)
...@@ -40,33 +34,43 @@ class Moniker: ...@@ -40,33 +34,43 @@ class Moniker:
def assert(self): def assert(self):
# Return true if the named object exists # Return true if the named object exists
if self.jr is None: jar=Globals.Bobobase._jar if self.jar is None: jar=Globals.Bobobase._jar
else: jar=Globals.SessionBase[self.jr].jar else: jar=Globals.SessionBase[self.jar].jar
for n in self.pd: for n in self.ids:
if not jar.has_key(n): if not jar.has_key(n):
return 0 return 0
return 1 return 1
def bind(self): def bind(self):
# Return the real object named by this moniker # Return the real object named by this moniker
if self.jr is None: jar=Globals.Bobobase._jar if self.jar is None: jar=Globals.Bobobase._jar
else: jar=Globals.SessionBase[self.jr].jar else: jar=Globals.SessionBase[self.jar].jar
ob=None ob=None
for n in self.pd: for n in self.ids:
o=jar[n] o=jar[n]
if ob is not None: if ob is not None:
o=o.__of__(ob) o=o.__of__(ob)
ob=o ob=o
return ob return ob
def exact(self, other): def exact(self, ob):
# Check against another moniker to see if it # Check against another moniker to see if it
# refers to the exact same object in the exact # refers to the exact same object in the exact
# same acquisition context. # same acquisition context.
return self.jr==other.jr and self.pd==other.pd return self.jar==ob.jar and self.ids==ob.ids
def absattr(attr): def absattr(attr):
if callable(attr): return attr() if callable(attr): return attr()
return attr return attr
##############################################################################
#
# $Log: Moniker.py,v $
# Revision 1.5 1998/08/14 16:46:36 brian
# Added multiple copy, paste, rename
#
__doc__="""Object Manager __doc__="""Object Manager
$Id: ObjectManager.py,v 1.44 1998/08/03 13:32:00 jim Exp $""" $Id: ObjectManager.py,v 1.45 1998/08/14 16:46:36 brian Exp $"""
__version__='$Revision: 1.44 $'[11:-2] __version__='$Revision: 1.45 $'[11:-2]
import Persistence, App.Management, Acquisition, App.Undo, Globals import Persistence, App.Management, Acquisition, App.Undo, Globals
import App.FactoryDispatcher import App.FactoryDispatcher
...@@ -106,15 +106,29 @@ class ObjectManager( ...@@ -106,15 +106,29 @@ class ObjectManager(
return () return ()
def _setObject(self,id,object,roles=None,user=None): def _setObject(self,id,object,roles=None,user=None):
self._checkId(id) self._checkId(id)
setattr(self,id,object) setattr(self,id,object)
try: t=object.meta_type try: t=object.meta_type
except: t=None except: t=None
self._objects=self._objects+({'id':id,'meta_type':t},) self._objects=self._objects+({'id':id,'meta_type':t},)
# This is a nasty hack that provides a workaround for any
# existing customers with the acl_users/__allow_groups__
# bug. Basically when you add an object, we'll do the check
# an make the fix if necessary.
have=self.__dict__.has_key
if have('__allow_groups__') and (not have('acl_users')):
delattr(self, '__allow_groups__')
def _delObject(self,id): def _delObject(self,id):
delattr(self,id) delattr(self,id)
if id=='acl_users':
# Yikes - acl_users is referred to by two names and
# must be treated as a special case!
try: delattr(self, '__allow_groups__')
except: pass
self._objects=tuple(filter(lambda i,n=id: i['id']!=n, self._objects)) self._objects=tuple(filter(lambda i,n=id: i['id']!=n, self._objects))
def objectIds(self, spec=None): def objectIds(self, spec=None):
...@@ -284,80 +298,33 @@ class ObjectManager( ...@@ -284,80 +298,33 @@ class ObjectManager(
manage_addProduct=App.FactoryDispatcher.ProductDispatcher() manage_addProduct=App.FactoryDispatcher.ProductDispatcher()
def manage_cutObject(self, ids, REQUEST=None):
"""Put a reference to an object, with the given id, in the clip board def manage_delObjects(self, ids=[], REQUEST=None):
The object is marked for deletion on paste. This is essentially
the first step in a move.
"""
if type(ids) is not type(''):
if len(ids) != 1:
return MessageDialog(
title='Invalid Selection',
message='Please select one and only one item to move',
action ='./manage_main',)
ids=ids[0]
obj=getattr(self, ids)
err=obj.cutToClipboard(REQUEST)
return err or self.manage_main(self, REQUEST, validClipData=1)
def manage_copyObject(self, ids, REQUEST=None):
"""Put a reference to an object, with the given id, in the clip board
"""
if type(ids) is not type(''):
if len(ids) != 1:
return MessageDialog(
title='Invalid Selection',
message='Please select one and only one item to move',
action ='./manage_main',)
ids=ids[0]
obj=getattr(self, ids)
err=obj.copyToClipboard(REQUEST)
return err or self.manage_main(self, REQUEST, validClipData=1)
def manage_pasteObject(self,clip_id='',clip_data='',REQUEST=None):
"""Paste from the clip board into the current object."""
return self.pasteFromClipboard(clip_id,clip_data,REQUEST)
def manage_delObjects(self, ids=[], submit='Delete',
clip_id='', clip_data='',REQUEST=None):
"""Delete a subordinate object """Delete a subordinate object
The objects specified in 'ids' get deleted. The objects specified in 'ids' get deleted.
""" """
if type(ids) is type(''): ids=[ids] if type(ids) is type(''): ids=[ids]
if submit=='Delete': if not ids:
if not ids: return MessageDialog(title='No items specified',
return MessageDialog(title='No items specified', message='No items were specified!',
message='No items were specified!', action ='./manage_main',)
action ='./manage_main',) try: p=self._reserved_names
except: p=()
try: p=self._reserved_names for n in ids:
except: p=() if n in p:
for n in ids: return MessageDialog(title='Not Deletable',
if n in p: message='<EM>%s</EM> cannot be deleted.' % n,
return MessageDialog(title='Not Deletable', action ='./manage_main',)
message='<EM>%s</EM> cannot be deleted.' % n, while ids:
action ='./manage_main',) id=ids[-1]
while ids: if not hasattr(self, id) or not self.__dict__.has_key(id):
id=ids[-1] raise 'BadRequest', '%s does not exist' % ids[-1]
if not hasattr(self, id) or not self.__dict__.has_key(id): self._delObject(id)
raise 'BadRequest', '%s does not exist' % ids[-1] del ids[-1]
self._delObject(id) if REQUEST is not None:
del ids[-1]
if REQUEST is not None:
return self.manage_main(self, REQUEST, update_menu=1) return self.manage_main(self, REQUEST, update_menu=1)
elif submit=='Cut': return self.manage_cutObject(id,REQURST)
elif submit=='Copy': return self.manage_copyObject(id,REQURST)
elif submit=='Paste':
return self.pasteFromClipboard(clip_id,clip_data,REQUEST)
def _setProperty(self,id,value,type='string'): def _setProperty(self,id,value,type='string'):
self._checkId(id) self._checkId(id)
...@@ -538,6 +505,9 @@ class ObjectManager( ...@@ -538,6 +505,9 @@ class ObjectManager(
############################################################################## ##############################################################################
# #
# $Log: ObjectManager.py,v $ # $Log: ObjectManager.py,v $
# Revision 1.45 1998/08/14 16:46:36 brian
# Added multiple copy, paste, rename
#
# Revision 1.44 1998/08/03 13:32:00 jim # Revision 1.44 1998/08/03 13:32:00 jim
# - Revamped folder security: # - Revamped folder security:
# #
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
<FORM ACTION="." METHOD="POST"> <FORM ACTION="." METHOD="POST">
<!--#if objectItems--> <!--#if objectItems-->
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING=2> <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2">
<!--#in objectItems sort--> <!--#in objectItems sort-->
<TR> <TR>
<TD ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH="16">
<INPUT TYPE="CHECKBOX" NAME="ids:list" VALUE="<!--#var sequence-key-->"> <INPUT TYPE="CHECKBOX" NAME="ids:list" VALUE="<!--#var sequence-key-->">
</TD> </TD>
<TD ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT" VALIGN="TOP">
...@@ -42,28 +42,31 @@ ...@@ -42,28 +42,31 @@
</TD> </TD>
</TR> </TR>
<!--#/in--> <!--#/in-->
<TR> </TABLE>
<TD></TD>
<TD COLSPAN="2"> <TABLE BORDER="0" CELLSPACING="0" CELLPADDING=2>
<INPUT TYPE="SUBMIT" NAME="manage_cutObject:method" VALUE="Cut"> <TR>
<INPUT TYPE="SUBMIT" NAME="manage_copyObject:method" VALUE="Copy"> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH="16"></TD>
<!--#if validClipData--> <TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="SUBMIT" NAME="manage_pasteObject:method" VALUE="Paste"> <INPUT TYPE="SUBMIT" NAME="manage_renameForm:method" VALUE="Rename">
<!--#/if validClipData--> <INPUT TYPE="SUBMIT" NAME="manage_cutObjects:method" VALUE="Cut">
<INPUT TYPE="SUBMIT" NAME="manage_delObjects:method" VALUE="Delete"> <INPUT TYPE="SUBMIT" NAME="manage_copyObjects:method" VALUE="Copy">
</TD> <!--#if cb_dataValid-->
<INPUT TYPE="SUBMIT" NAME="manage_pasteObjects:method" VALUE="Paste">
<!--#/if-->
<INPUT TYPE="SUBMIT" NAME="manage_delObjects:method" VALUE="Delete">
</TD>
</TR> </TR>
</TABLE> </TABLE>
<!--#else--> <!--#else-->
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING=2> <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2">
<TR> <TR>
<TD> <TD>
There are currently no items in <EM><!--#var title_or_id--></EM> There are currently no items in <EM><!--#var title_or_id--></EM>
<P> <P>
<!--#if validClipData--> <!--#if cb_dataValid-->
<INPUT TYPE="SUBMIT" NAME="manage_pasteObject:method" VALUE="Paste"> <INPUT TYPE="SUBMIT" NAME="manage_pasteObjects:method" VALUE="Paste">
<!--#/if validClipData--> <!--#/if-->
</TD> </TD>
</TABLE> </TABLE>
<!--#/if--> <!--#/if-->
......
<HTML>
<HEAD>
<TITLE>Rename Item</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#if expr="_.hasattr(REQUEST, 'ids') and REQUEST['ids']"-->
<!--#with expr="_.getattr(this(), REQUEST['ids'][0])"-->
<!--#if cb_isMoveable-->
<H2>Rename <!--#var meta_type--></H2>
<P>
<FORM ACTION="." METHOD="POST">
<TABLE CELLSPACING="0">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<IMG SRC="<!--#var SCRIPT_NAME-->/<!--#var icon-->" ALT="" BORDER="0">
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<!--#var id-->
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<STRONG>to:</STRONG>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="new_id" SIZE="20">
</TD>
</TR>
<TR>
<TD></TD>
<TD>
<INPUT TYPE="HIDDEN" NAME="id" VALUE="<!--#var id-->">
<INPUT TYPE="submit" NAME="manage_renameObject:method" VALUE=" Ok ">
<INPUT TYPE="submit" NAME="manage_main:method" VALUE="Cancel">
</TD>
</TR>
</TABLE>
</FORM>
<!--#else-->
<FORM ACTION="manage_main" METHOD="GET">
<CENTER>
<BR><BR>
The item <EM><!--#var id--></EM> does not support this operation.
<P>
<INPUT TYPE="submit" NAME="submit" VALUE=" Ok ">
</CENTER>
</FORM>
<!--#/if-->
<!--#/with-->
<!--#else-->
<FORM ACTION="manage_main" METHOD="GET">
<CENTER>
<BR><BR>
You must select an item to rename.
<P>
<INPUT TYPE="submit" NAME="submit" VALUE=" Ok ">
</CENTER>
</FORM>
<!--#/if-->
</BODY>
</HTML>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment