Commit 96dcc637 authored by Jim Fulton's avatar Jim Fulton

- Revamped folder security:

         - No longer a separate "add objects" permission.

         - Must have "view management screens" to copy.

         - Must have "delete objects" to cut ot delete.

         - Must be able to add an object of the type being pasted.

      - Through-the-web creation of products and factories.
parent 0eeec45e
__doc__="""Object Manager
$Id: ObjectManager.py,v 1.43 1998/07/23 17:16:52 jim Exp $"""
$Id: ObjectManager.py,v 1.44 1998/08/03 13:32:00 jim Exp $"""
__version__='$Revision: 1.43 $'[11:-2]
__version__='$Revision: 1.44 $'[11:-2]
import Persistence, App.Management, Acquisition, App.Undo, Globals
import App.FactoryDispatcher
from Globals import HTMLFile, HTMLFile
from Globals import MessageDialog, default__class_init__
from string import find,join,lower
from string import find,join,lower,split
from urllib import quote
from DocumentTemplate import html_quote
from cgi_module_publisher import type_converters
......@@ -64,7 +65,12 @@ class ObjectManager(
default__class_init__(self)
def all_meta_types(self):
return self.meta_types+self.dynamic_meta_types
pmt=()
if hasattr(self, '_product_meta_types'): pmt=self._product_meta_types
elif hasattr(self, 'aq_acquire'):
try: pmt=self.aq_acquire('_product_meta_types')
except: pass
return self.meta_types+self.dynamic_meta_types+pmt
def _checkId(self,id):
......@@ -275,57 +281,52 @@ class ObjectManager(
x=x+1
return vals
def manage_addObject(self,type,REQUEST):
"""Add a subordinate object"""
for t in self.meta_types:
if t['name']==type:
return getattr(self,t['action'])(
self,REQUEST,
aclEChecked='', aclAChecked=' CHECKED', aclPChecked=''
)
for t in self.dynamic_meta_types:
if t['name']==type:
return getattr(self,t['action'])(
self,REQUEST,
aclEChecked='', aclAChecked=' CHECKED', aclPChecked='')
raise 'BadRequest', 'Unknown object type: %s' % type
def manage_delObjects(self,ids=[],submit='',clip_id='',
clip_data='',REQUEST=None):
"""Copy/Paste/Delete a subordinate object
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):
"""Delete a subordinate object
Based on the value of 'submit', the objects specified in 'ids' get
copied, pasted, or deleted. 'Copy' can only work on one object id.
'Paste' uses the parameters 'clip_id' and 'clip_data' to paste.
'Delete' removes the objects specified in 'ids'.
The objects specified in 'ids' get deleted.
"""
if submit=='Cut':
c=len(ids)
if (c <= 0) or (c > 1):
return MessageDialog(
title='Invalid Selection',
message='Please select one and only one item to move',
action ='./manage_main',)
obj=getattr(self, ids[0])
err=obj.cutToClipboard(REQUEST)
return err or self.manage_main(self, REQUEST, validClipData=1)
if submit=='Copy':
c=len(ids)
if (c <= 0) or (c > 1):
return MessageDialog(
title='Invalid Selection',
message='Please select one and only one item to copy',
action ='./manage_main',)
obj=getattr(self, ids[0])
err=obj.copyToClipboard(REQUEST)
return err or self.manage_main(self, REQUEST, validClipData=1)
if submit=='Paste':
return self.pasteFromClipboard(clip_id,clip_data,REQUEST)
if type(ids) is type(''): ids=[ids]
if submit=='Delete':
if not ids:
return MessageDialog(title='No items specified',
......@@ -340,12 +341,23 @@ class ObjectManager(
message='<EM>%s</EM> cannot be deleted.' % n,
action ='./manage_main',)
while ids:
try: self._delObject(ids[-1])
except: raise 'BadRequest', ('%s does not exist' % ids[-1])
id=ids[-1]
if not hasattr(self, id) or not self.__dict__.has_key(id):
raise 'BadRequest', '%s does not exist' % ids[-1]
self._delObject(id)
del ids[-1]
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)
......@@ -526,6 +538,19 @@ class ObjectManager(
##############################################################################
#
# $Log: ObjectManager.py,v $
# Revision 1.44 1998/08/03 13:32:00 jim
# - Revamped folder security:
#
# - No longer a separate "add objects" permission.
#
# - Must have "view management screens" to copy.
#
# - Must have "delete objects" to cut ot delete.
#
# - Must be able to add an object of the type being pasted.
#
# - Through-the-web creation of products and factories.
#
# Revision 1.43 1998/07/23 17:16:52 jim
# Fixed ornery bug in objectItems.
#
......
......@@ -10,8 +10,8 @@
<P>
<!--#/if Principia-Session-->
<FORM ACTION="manage_delObjects" METHOD="POST">
<!--#if objectValues-->
<FORM ACTION="." METHOD="POST">
<!--#if objectItems-->
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING=2>
<!--#in objectItems sort-->
<TR>
......@@ -28,7 +28,7 @@
<!--#var sequence-key-->
<!--#if title-->
(<!--#var title-->)
<!--#/if title-->
<!--#/if-->
</A>
<!--#if locked_in_session-->
<!--#if modified_in_session-->
......@@ -41,32 +41,32 @@
<!--#/if-->
</TD>
</TR>
<!--#/in objectValues-->
<!--#/in-->
<TR>
<TD></TD>
<TD COLSPAN="2">
<INPUT TYPE="SUBMIT" NAME="submit" VALUE="Cut">
<INPUT TYPE="SUBMIT" NAME="submit" VALUE="Copy">
<INPUT TYPE="SUBMIT" NAME="manage_cutObject:method" VALUE="Cut">
<INPUT TYPE="SUBMIT" NAME="manage_copyObject:method" VALUE="Copy">
<!--#if validClipData-->
<INPUT TYPE="SUBMIT" NAME="submit" VALUE="Paste">
<INPUT TYPE="SUBMIT" NAME="manage_pasteObject:method" VALUE="Paste">
<!--#/if validClipData-->
<INPUT TYPE="SUBMIT" NAME="submit" VALUE="Delete">
<INPUT TYPE="SUBMIT" NAME="manage_delObjects:method" VALUE="Delete">
</TD>
</TR>
</TABLE>
<!--#else objectValues-->
<!--#else-->
<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="submit" VALUE="Paste">
<INPUT TYPE="SUBMIT" NAME="manage_pasteObject:method" VALUE="Paste">
<!--#/if validClipData-->
</TD>
</TABLE>
<!--#/if objectValues-->
<!--#/if-->
</FORM>
<TABLE>
......@@ -75,10 +75,10 @@ There are currently no items in <EM><!--#var title_or_id--></EM>
To add a new item, select an item type and click &quot;Add&quot;.
</TD>
<TD VALIGN="TOP">
<FORM ACTION="manage_addObject" METHOD="GET">
<SELECT NAME="type">
<FORM ACTION="." METHOD="GET">
<SELECT NAME=":method">
<!--#in all_meta_types mapping-->
<OPTION><!--#var name-->
<OPTION value="<!--#var action-->"><!--#var name-->
<!--#/in all_meta_types-->
</SELECT><BR>
<INPUT TYPE="SUBMIT" VALUE=" Add ">
......
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