Commit 9bef361c authored by Jim Fulton's avatar Jim Fulton

Added checks to prevent moving uncommitted sessions and drafts

parent 1ff51999
......@@ -46,10 +46,12 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
self.__allow_groups__=uf
def icon(self):
return getattr(self.aq_parent.aq_base,self._refid).icon
try: return getattr(self.aq_parent.aq_base,self._refid).icon
except: return 'p_/broken'
def manage_options(self):
return getattr(self.aq_parent.aq_base,self._refid).manage_options
try: return getattr(self.aq_parent.aq_base,self._refid).manage_options
except: return ()
def title(self):
return 'draft of '+self._refid
......@@ -94,7 +96,25 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
Globals.SessionBase[self._session].abort()
if REQUEST:
REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main')
def _notifyOfCopyTo(self, container, isMove=0):
if isMove and self.nonempty():
raise 'Copy Error', (
"You cannot copy a %s object with <b>unapproved</b> changes.\n"
"You must <b>approve</b> the changes first."
% self.meta_type)
def _postCopy(self, container, op=0):
try:
session=self.REQUEST['PATH_INFO']
l=rfind(session,'/')
if l >= 0: session=session[:l]
self._session="%s/%s" % (session, self.id)
finally:
if 0:
raise 'Copy Error', (
"This object can only be copied through the web.<p>")
def getdraft(ob, session):
if hasattr(ob,'aq_parent'):
......
"""Session object"""
__version__='$Revision: 1.20 $'[11:-2]
__version__='$Revision: 1.21 $'[11:-2]
import Globals, time
from AccessControl.Role import RoleManager
......@@ -113,7 +113,13 @@ class Session(Persistent,Implicit,RoleManager,Item):
if REQUEST: return self.manage_main(self, REQUEST)
def nonempty(self): return Globals.SessionBase[self.cookie].nonempty()
def _notifyOfCopyTo(self, container, isMove=0):
if isMove and self.nonempty():
raise 'Copy Error', (
"You cannot copy a %s object with <b>unsaved</b> changes.\n"
"You must <b>save</b> the changes first."
% self.meta_type)
import __init__
......@@ -123,6 +129,9 @@ __init__.need_license=1
##############################################################################
#
# $Log: Session.py,v $
# Revision 1.21 1998/09/24 20:13:40 jim
# Added checks to prevent moving uncommitted sessions and drafts
#
# Revision 1.20 1998/09/24 19:21:52 jim
# added Draft objects
#
......
"""Session object"""
__version__='$Revision: 1.20 $'[11:-2]
__version__='$Revision: 1.21 $'[11:-2]
import Globals, time
from AccessControl.Role import RoleManager
......@@ -113,7 +113,13 @@ class Session(Persistent,Implicit,RoleManager,Item):
if REQUEST: return self.manage_main(self, REQUEST)
def nonempty(self): return Globals.SessionBase[self.cookie].nonempty()
def _notifyOfCopyTo(self, container, isMove=0):
if isMove and self.nonempty():
raise 'Copy Error', (
"You cannot copy a %s object with <b>unsaved</b> changes.\n"
"You must <b>save</b> the changes first."
% self.meta_type)
import __init__
......@@ -123,6 +129,9 @@ __init__.need_license=1
##############################################################################
#
# $Log: Version.py,v $
# Revision 1.21 1998/09/24 20:13:40 jim
# Added checks to prevent moving uncommitted sessions and drafts
#
# Revision 1.20 1998/09/24 19:21:52 jim
# added Draft objects
#
......
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