Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Commit

Permalink
Added checks to prevent moving uncommitted sessions and drafts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Fulton committed Sep 24, 1998
1 parent 271b0f1 commit 2bc61d1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
26 changes: 23 additions & 3 deletions Draft.py
Expand Up @@ -46,10 +46,12 @@ def __init__(self, id, baseid, PATH_INFO):
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
Expand Down Expand Up @@ -94,7 +96,25 @@ def manage_Discard__draft__(self, REQUEST=None):
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'):
Expand Down
13 changes: 11 additions & 2 deletions Session.py
@@ -1,6 +1,6 @@
"""Session object"""

__version__='$Revision: 1.20 $'[11:-2]
__version__='$Revision: 1.21 $'[11:-2]

import Globals, time
from AccessControl.Role import RoleManager
Expand Down Expand Up @@ -113,7 +113,13 @@ def discard(self, REQUEST=None):
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__
Expand All @@ -123,6 +129,9 @@ def nonempty(self): return Globals.SessionBase[self.cookie].nonempty()
##############################################################################
#
# $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
#
Expand Down
13 changes: 11 additions & 2 deletions Version.py
@@ -1,6 +1,6 @@
"""Session object"""

__version__='$Revision: 1.20 $'[11:-2]
__version__='$Revision: 1.21 $'[11:-2]

import Globals, time
from AccessControl.Role import RoleManager
Expand Down Expand Up @@ -113,7 +113,13 @@ def discard(self, REQUEST=None):
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__
Expand All @@ -123,6 +129,9 @@ def nonempty(self): return Globals.SessionBase[self.cookie].nonempty()
##############################################################################
#
# $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
#
Expand Down

0 comments on commit 2bc61d1

Please sign in to comment.