Commit da476c61 authored by 's avatar

Added multiple copy, paste, rename

parent ee6c5127
This diff is collapsed.
"""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
......@@ -71,7 +71,8 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
('View management screens',
('manage','manage_menu','manage_main','manage_copyright',
'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_findResult', 'manage_findOpt')),
('Access contents information',
......
"""
Object monikers
"""Object monikers
An object moniker is an intelligent reference to a
persistent object. A moniker can be turned back into
......@@ -7,30 +6,25 @@ Object monikers
and aquisition relationships via a simple interface.
"""
__version__='$Revision: 1.4 $'[11:-2]
__version__='$Revision: 1.5 $'[11:-2]
import Globals
class Moniker:
""" """
def __init__(self, obj=None, op=0):
if obj is None: return
pd=[]
ob=obj
def __init__(self, ob=None):
if ob is None: return
self.jar=ob._p_jar.name
self.ids=[]
while 1:
if not hasattr(ob, '_p_oid'):
break
pd.append(ob._p_oid)
self.ids.append(ob._p_oid)
if not hasattr(ob, 'aq_parent'):
break
ob=ob.aq_parent
pd.reverse()
self.pd=pd
self.jr=obj._p_jar.name
self.op=op
self.ids.reverse()
def id(self):
return absattr(self.bind().id)
......@@ -40,33 +34,43 @@ class Moniker:
def assert(self):
# Return true if the named object exists
if self.jr is None: jar=Globals.Bobobase._jar
else: jar=Globals.SessionBase[self.jr].jar
for n in self.pd:
if self.jar is None: jar=Globals.Bobobase._jar
else: jar=Globals.SessionBase[self.jar].jar
for n in self.ids:
if not jar.has_key(n):
return 0
return 1
def bind(self):
# Return the real object named by this moniker
if self.jr is None: jar=Globals.Bobobase._jar
else: jar=Globals.SessionBase[self.jr].jar
if self.jar is None: jar=Globals.Bobobase._jar
else: jar=Globals.SessionBase[self.jar].jar
ob=None
for n in self.pd:
for n in self.ids:
o=jar[n]
if ob is not None:
o=o.__of__(ob)
ob=o
return ob
def exact(self, other):
def exact(self, ob):
# Check against another moniker to see if it
# refers to the exact same object in the exact
# 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):
if callable(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
$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 App.FactoryDispatcher
......@@ -106,15 +106,29 @@ class ObjectManager(
return ()
def _setObject(self,id,object,roles=None,user=None):
self._checkId(id)
setattr(self,id,object)
try: t=object.meta_type
except: t=None
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):
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))
def objectIds(self, spec=None):
......@@ -284,55 +298,17 @@ class ObjectManager(
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
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):
def manage_delObjects(self, ids=[], REQUEST=None):
"""Delete a subordinate object
The objects specified in 'ids' get deleted.
"""
if type(ids) is type(''): ids=[ids]
if submit=='Delete':
if not ids:
return MessageDialog(title='No items specified',
message='No items were specified!',
action ='./manage_main',)
try: p=self._reserved_names
except: p=()
for n in ids:
......@@ -349,15 +325,6 @@ class ObjectManager(
if REQUEST is not None:
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'):
self._checkId(id)
......@@ -538,6 +505,9 @@ class ObjectManager(
##############################################################################
#
# $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
# - Revamped folder security:
#
......
......@@ -12,10 +12,10 @@
<FORM ACTION="." METHOD="POST">
<!--#if objectItems-->
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING=2>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2">
<!--#in objectItems sort-->
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="16">
<INPUT TYPE="CHECKBOX" NAME="ids:list" VALUE="<!--#var sequence-key-->">
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
......@@ -42,28 +42,31 @@
</TD>
</TR>
<!--#/in-->
<TR>
<TD></TD>
</TABLE>
<TD COLSPAN="2">
<INPUT TYPE="SUBMIT" NAME="manage_cutObject:method" VALUE="Cut">
<INPUT TYPE="SUBMIT" NAME="manage_copyObject:method" VALUE="Copy">
<!--#if validClipData-->
<INPUT TYPE="SUBMIT" NAME="manage_pasteObject:method" VALUE="Paste">
<!--#/if validClipData-->
<INPUT TYPE="SUBMIT" NAME="manage_delObjects:method" VALUE="Delete">
</TD>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING=2>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="16"></TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="SUBMIT" NAME="manage_renameForm:method" VALUE="Rename">
<INPUT TYPE="SUBMIT" NAME="manage_cutObjects:method" VALUE="Cut">
<INPUT TYPE="SUBMIT" NAME="manage_copyObjects:method" VALUE="Copy">
<!--#if cb_dataValid-->
<INPUT TYPE="SUBMIT" NAME="manage_pasteObjects:method" VALUE="Paste">
<!--#/if-->
<INPUT TYPE="SUBMIT" NAME="manage_delObjects:method" VALUE="Delete">
</TD>
</TR>
</TABLE>
<!--#else-->
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING=2>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2">
<TR>
<TD>
There are currently no items in <EM><!--#var title_or_id--></EM>
<P>
<!--#if validClipData-->
<INPUT TYPE="SUBMIT" NAME="manage_pasteObject:method" VALUE="Paste">
<!--#/if validClipData-->
<!--#if cb_dataValid-->
<INPUT TYPE="SUBMIT" NAME="manage_pasteObjects:method" VALUE="Paste">
<!--#/if-->
</TD>
</TABLE>
<!--#/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