Commit 7299aa7c authored by Jim Fulton's avatar Jim Fulton

Moved session and draft folder stuff to Products/OFSP

parent 471dd19c
#!/bin/env python
##############################################################################
#
# Copyright
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
# rights reserved.
#
##############################################################################
__doc__='''\
Provide an area where people can work without others seeing their changes.
A Draft folder is a surrogate for a folder. It get\'s subobjects by
gettingthem from a session copy of a base folder.
$Id: DraftFolder.py,v 1.6 1997/12/31 17:22:51 brian Exp $'''
__version__='$Revision: 1.6 $'[11:-2]
import time, SimpleItem, AccessControl.Role, Persistence, Acquisition, Globals
import AccessControl.User, Session
from string import rfind
from App.Management import Management
from Globals import HTMLFile
from ImageFile import ImageFile
addForm=HTMLFile('draftFolderAdd', globals())
def add(self,id,baseid,title='',REQUEST=None):
"""Add a new Folder object"""
i=DraftFolder()
i._init(id, baseid, title, self,REQUEST)
self._setObject(id,i)
if REQUEST is not None: return self.manage_main(self,REQUEST)
def hack(self):
return ({'icon':icon, 'label':'Contents',
'action':'manage_main', 'target':'manage_main'},
{'icon':'OFS/Properties_icon.gif', 'label':'Properties',
'action':'manage_propertiesForm', 'target':'manage_main'},
{'icon':'', 'label':'Security',
'action':'manage_access', 'target':'manage_main'},
{'icon':'App/undo_icon.gif', 'label':'Undo',
'action':'manage_UndoForm', 'target':'manage_main'},
{'icon':'OFS/DraftFolderControl.gif', 'label':'Supervise',
'action':'manage_Supervise', 'target':'manage_main'},
)
class DraftFolder(Persistence.Persistent,
AccessControl.Role.RoleManager,
SimpleItem.Item,
Acquisition.Implicit,
Management,
):
meta_type='Draft Folder'
icon='DraftFolderIcon'
DraftFolderIcon=ImageFile('www/DraftFolder.gif', globals())
isPrincipiaFolderish=1
manage_options=(
{'icon':icon, 'label':'Contents',
'action':'manage_main', 'target':'manage_main'},
{'icon':'OFS/Properties_icon.gif', 'label':'Properties',
'action':'manage_propertiesForm', 'target':'manage_main'},
{'icon':'', 'label':'Security',
'action':'manage_access', 'target':'manage_main'},
{'icon':'App/undo_icon.gif', 'label':'Undo',
'action':'manage_UndoForm', 'target':'manage_main'},
{'icon':'OFS/DraftFolderControl.gif', 'label':'Supervise',
'action':'manage_Supervise', 'target':'manage_main'},
)
def _init(self, id, baseid, title, parent, REQUEST):
if hasattr(parent, 'aq_self'): parent=parent.aq_self
if not hasattr(parent, baseid):
raise 'Input Error', (
'The specified base folder, %s, does not exist'
% baseid
)
self.id=id
self.baseid=baseid
self.title=title
cookie=REQUEST['PATH_INFO']
if cookie[:1] != '/': cookie='/'+cookie
l=rfind(cookie,'/')
if l >= 0: cookie=cookie[:l]
self.cookie="%s/%s" % (cookie, id)
self.cookie_name="%s-Draft-Folder-%s" % (id,baseid)
self.__allow_groups__=Supervisor()
self.__allow_groups__._init()
def title_and_id(self):
r=DraftFolder.inheritedAttribute('title_and_id')(self)
r='%s *' % r
try: base=getattr(self.aq_parent, self.baseid)
except: base=None
if base is not None:
r="%s Draft Folder: %s" % (base.title_or_id(), r)
return r
def _base(self, cookie):
# Check for base object
if hasattr(self, 'aq_parent'): parent=self.aq_parent
else: parent=None
if hasattr(parent, 'aq_self'): ps=parent.aq_self
else: ps=parent
baseid=self.baseid
if not hasattr(ps, baseid):
raise 'Draft Folder Error', (
'''The base folder for the draft folder, <em>%s</em>,
does not exist.'''
% self.cookie
)
base=getattr(parent, baseid)
pd=Globals.SessionBase[cookie]
oids=[base._p_oid]
while hasattr(base, 'aq_parent'):
base=base.aq_parent
if hasattr(base, '_p_oid'): oids.append(base._p_oid)
else: break
while oids:
oid=oids[-1]
del oids[-1]
base=pd.jar[oid].__of__(base)
base.manage_options=hack
return base
def __bobo_traverse__(self, REQUEST, name):
cookie_name=self.cookie_name
cookie=''
if REQUEST.has_key(cookie_name):
if REQUEST[cookie_name] == self.cookie:
cookie=self.cookie
else:
# Oops, the cookie is broken, better erase it:
RESPONSE=REQUEST['RESPONSE']
RESPONSE.setCookie(
self.cookie_name,'No longer active',
expires="Mon, 27-Aug-84 23:59:59 GMT",
path=REQUEST['SCRIPT_NAME']+self.cookie,
)
REQUEST[self.cookie_name]=''
PATH_INFO=REQUEST['PATH_INFO']
if PATH_INFO[:1] != '/': PATH_INFO='/'+PATH_INFO
if PATH_INFO==self.cookie+'/manage':
if not cookie: return self.manage
return Management.manage
if PATH_INFO==self.cookie+'/manage_menu': return self.manage_menu
if name=='manage_Supervise':
raise 'Redirect', (
"%s/manage_draftFolder-%s/manage"
% (REQUEST['URL2'], self.id))
if not cookie:
# Just set cookie here, rather than redirect!
cookie=self.cookie
cookie_name=self.cookie_name
REQUEST['RESPONSE'].setCookie(cookie_name, cookie,
expires="Mon, 27-Dec-99 23:59:59 GMT",
path=REQUEST['SCRIPT_NAME']+cookie,)
REQUEST[cookie_name]=cookie
__traceback_info__=PATH_INFO, cookie, self.cookie
self=self._base(cookie)
try:
v=getattr(self, name)
if hasattr(v, 'isDocTemp') and v.isDocTemp and (
PATH_INFO=="%s/%s" % (cookie, name) or
PATH_INFO==cookie and name=='index_html'
):
def v(REQUEST, _dt_=v, _self_=self):
"Damn, need this so template gets called with right thing"
return _dt_(_self_, REQUEST)
return v
except AttributeError:
try: return self[name]
except KeyError:
raise 'NotFound',(
"Sorry, the requested document does not exist.<p>"
"\n<!--\n%s\n%s\n-->" % (name,REQUEST['REQUEST_METHOD']))
def manage_supervisor(self): return self.__allow_groups__
def parentObject(self):
try: return (self.aq_parent,)
except: return ()
class Supervisor(AccessControl.User.UserFolder, Session.Session):
manage=manage_main=HTMLFile('DraftFolderSupervisor', globals())
manage_options=() # This is a simple item
##############################################################################
#
# $Log: DraftFolder.py,v $
# Revision 1.6 1997/12/31 17:22:51 brian
# Security update
#
# Revision 1.5 1997/12/18 16:45:40 jeffrey
# changeover to new ImageFile and HTMLFile handling
#
# Revision 1.4 1997/12/12 21:49:42 brian
# ui update
#
# Revision 1.3 1997/12/05 20:33:02 brian
# *** empty log message ***
#
# Revision 1.2 1997/11/11 21:25:28 brian
# Added copy/paste support, restricted unpickling, fixed DraftFolder bug
#
# Revision 1.1 1997/11/11 21:05:44 jim
# Draft Folders
#
#
<HTML>
<HEAD>
<TITLE>Draft Supervisor</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B">
<H2>Draft Supervision</H2>
<h3>Draft Folder Approval</h3>
<!--#if nonempty-->
<p><form action=save>
You can make work done in <!--#var title_and_id--> permanent by
entering a remark in the space below and then
clicking on the "Save" button.<br>
<textarea name=remark rows=10 cols=50></textarea><br>
<input type=submit value="Save">
</form>
<hr>
<p><form action=discard>
You can throw away work done in <!--#var title_and_id--> by
clicking on the "Discard" button.
<input type=submit value="Discard">
</form>
<!--#else-->
<p>No work has been done in <!--#var title_and_id--> yet.</p>
<!--#/if-->
<hr>
<h3>Draft Folder Users</h3>
<!--#if userNames-->
<FORM ACTION="manage_editForm" METHOD="POST">
The following users have been defined. To edit a user,
select a user and click &quot;Edit&quot;.
<BR>
<SELECT NAME="name">
<!--#in userNames-->
<OPTION VALUE="<!--#var sequence-item-->"> <!--#var sequence-item-->
<!--#/in userNames-->
</SELECT>
<BR>
<INPUT TYPE="SUBMIT" VALUE=" Change ">
</FORM>
<!--#else userNames-->
<EM>There are no users defined.</EM>
<!--#/if userNames-->
<P>
<TABLE>
<TR>
<TD COLSPAN="2" VALIGN="TOP">
To add a new user, enter the name, password, confirmation and
roles for the new user and click &quot;Add&quot;.
</TD>
</TR>
<TR>
<TD COLSPAN="2" VALIGN="TOP">
<FORM ACTION="manage_addUser" METHOD="POST">
<TABLE>
<TR>
<TD VALIGN="TOP">
<STRONG>Name</STRONG>
</TD>
<TD VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="name" SIZE="20">
</TD>
</TR>
<TR>
<TD VALIGN="TOP">
<STRONG>Password</STRONG>
</TD>
<TD VALIGN="TOP">
<INPUT TYPE="PASSWORD" NAME="password" SIZE="20">
</TD>
</TR>
<TR>
<TD VALIGN="TOP">
<STRONG>(Confirm)</STRONG>
</TD>
<TD VALIGN="TOP">
<INPUT TYPE="PASSWORD" NAME="confirm" SIZE="20">
</TD>
</TR>
<TR>
<TD VALIGN="TOP">
<STRONG>Roles</STRONG>
</TD>
<TD VALIGN="TOP">
<SELECT NAME="roles:list" SIZE="5" MULTIPLE>
<!--#if roleNames-->
<!--#in roleNames-->
<OPTION><!--#var sequence-item-->
<!--#/in roleNames-->
<!--#/if roleNames-->
</SELECT>
<BR>
<INPUT TYPE="SUBMIT" VALUE=" Add ">
</TD>
</TR>
</TABLE>
</FORM>
</TD>
</TR>
</TABLE>
<P>
<!--#if userNames-->
<FORM ACTION="manage_deleteUser" METHOD="POST">
To delete users, select one or more users and click &quot;Delete&quot;.
<BR>
<SELECT NAME="names:list" MULTIPLE SIZE="4" >
<!--#in userNames-->
<OPTION><!--#var sequence-item-->
<!--#/in userNames-->
</SELECT>
<BR>
<INPUT TYPE="SUBMIT" VALUE="Delete">
</FORM>
<!--#/if userNames-->
</BODY>
</HTML>
#!/bin/env python
##############################################################################
#
# Copyright
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
# rights reserved.
#
##############################################################################
__doc__='''A drop-in object that represents a session.
$Id: Session.py,v 1.10 1997/12/31 17:13:25 brian Exp $'''
import time, SimpleItem, AccessControl.Role, Persistence, Acquisition, Globals
from string import rfind
from ImageFile import ImageFile
_addForm=Globals.HTMLFile('sessionAdd', globals())
def addForm(realself, self, REQUEST, **ignored):
return _addForm(self, REQUEST)
def add(self, id, title, REQUEST=None):
'Add a session'
i=Session()
i._init(id, title, REQUEST)
self._setObject(id,i)
return self.manage_main(self,REQUEST)
class Session(Persistence.Persistent,
AccessControl.Role.RoleManager,
SimpleItem.Item,
Acquisition.Implicit):
'''Model sessions as drop-in objects
'''
meta_type='Session'
icon='SessionIcon'
SessionIcon=ImageFile('www/session.gif', globals())
manage_options=({'icon':'', 'label':'Join/Leave',
'action':'manage_main', 'target':'manage_main',
},
{'icon':'', 'label':'Properties',
'action':'manage_propertiesForm', 'target':'manage_main',
},
{'icon':'', 'label':'Security',
'action':'manage_access', 'target':'manage_main',
},
{'icon':'', 'label':'Undo',
'action':'manage_UndoForm','target':'manage_main',
},
)
__ac_permissions__=(
('View management screens', ['manage','manage_tabs','index_html']),
('Change permissions', ['manage_access']),
('Edit session', ['manage_edit']),
('Join/leave session', ['enter','leave','leave_another']),
('Save/discard session', ['save','discard']),
)
__ac_types__=(('Full Access', map(lambda x: x[0], __ac_permissions__)),
)
def _init(self, id, title, REQUEST):
self.id=id
self.title=title
cookie=REQUEST['PATH_INFO']
l=rfind(cookie,'/')
if l >= 0: cookie=cookie[:l]
self.cookie="%s/%s" % (cookie, id)
manage=manage_main=Globals.HTMLFile('sessionEdit', globals())
index_html=Globals.HTMLFile('session', globals())
def title_and_id(self):
r=Session.inheritedAttribute('title_and_id')(self)
if Globals.SessionBase[self.cookie].nonempty(): return '%s *' % r
return r
def manage_edit(self, title, REQUEST=None):
'Modify a session'
self.title=title
if REQUEST is not None: return self.manage_editedDialog(REQUEST)
def enter(self, REQUEST, RESPONSE):
'Begin working in a session'
RESPONSE.setCookie(
Globals.SessionNameName, self.cookie,
expires="Mon, 27-Dec-99 23:59:59 GMT",
path=REQUEST['SCRIPT_NAME'],
)
REQUEST[Globals.SessionNameName]=self.cookie
return self.index_html(self, REQUEST)
def leave(self, REQUEST, RESPONSE):
'Temporarily stop working in a session'
RESPONSE.setCookie(
Globals.SessionNameName,'No longer active',
expires="Mon, 27-Aug-84 23:59:59 GMT",
path=REQUEST['SCRIPT_NAME'],
)
REQUEST[Globals.SessionNameName]=''
return self.index_html(self, REQUEST)
def leave_another(self, REQUEST, RESPONSE):
'Leave a session that may not be the current session'
self.leave(REQUEST, RESPONSE)
RESPONSE.setStatus(302)
RESPONSE['Location']=REQUEST['URL2']+'/manage_main'
def save(self, remark, REQUEST):
'Make session changes permanent'
Globals.SessionBase[self.cookie].commit(remark)
if REQUEST is not None: return self.index_html(self, REQUEST)
def discard(self, REQUEST):
'Discard changes made during the session'
Globals.SessionBase[self.cookie].abort()
if REQUEST is not None: return self.index_html(self, REQUEST)
def nonempty(self): return Globals.SessionBase[self.cookie].nonempty()
__version__='$Revision: 1.10 $'[11:-2]
##############################################################################
#
# $Log: Session.py,v $
# Revision 1.10 1997/12/31 17:13:25 brian
# Security changes
#
# Revision 1.9 1997/12/31 16:53:42 brian
# Added security info
#
# Revision 1.8 1997/12/18 16:42:02 jeffrey
# *** empty log message ***
#
# Revision 1.7 1997/12/18 13:36:57 jim
# Rearranged management options to make the join/leave screen the
# default.
#
# Revision 1.6 1997/12/12 21:49:44 brian
# ui update
#
# Revision 1.5 1997/12/05 17:13:51 brian
# New UI
#
# Revision 1.4 1997/11/11 19:25:48 jim
# Changed title_and_id method to include a flag to indicate whether a
# session has unsaved changes.
#
# Revision 1.3 1997/11/07 18:51:13 jim
# Made an implicit acquirer.
#
# Revision 1.2 1997/11/07 17:43:19 jim
# Added a feature to exit another session.
#
# Revision 1.1 1997/11/07 16:13:15 jim
# *** empty log message ***
#
#
##############################################################################
#
# Copyright
#
# Copyright 1997 Digital Creations, L.C., 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
# rights reserved.
#
##############################################################################
__doc__='''OFS
$Id: __init__.py,v 1.4 1997/12/19 19:11:18 jim Exp $'''
__version__='$Revision: 1.4 $'[11:-2]
import Session, DraftFolder
p_={}
##############################################################################
#
# $Log: __init__.py,v $
# Revision 1.4 1997/12/19 19:11:18 jim
# updated icon management strategy
#
# Revision 1.3 1997/11/11 19:26:37 jim
# Added DraftFolder.
#
# Revision 1.2 1997/11/10 16:32:54 jim
# Changed to support separate Image and File objects.
#
# Revision 1.1 1997/11/07 19:31:42 jim
# *** empty log message ***
#
# Revision 1.1 1997/10/09 17:34:53 jim
# first cut, no testing
#
# Revision 1.1 1997/07/25 18:14:28 jim
# initial
#
#
<HTML>
<HEAD>
<TITLE>Add Draft Folder</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<H2>Add Draft Folder</H2>
<FORM ACTION="manage_addDraftFolder" METHOD="POST">
<TABLE CELLSPACING="2">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<STRONG>Id</STRONG>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="id" SIZE="40">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<EM><STRONG>Title</STRONG></EM>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="title" SIZE="40">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<EM><STRONG>Base Folder</STRONG></EM>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<SELECT NAME=baseid>
<!--#in folderValues-->
<OPTION VALUE="<!--#var id-->">
<!--#if title-->
<!--#var title size=25--> (<!--#var id-->)
<!--#else-->
<!--#var id-->
<!--#endif-->
<!--#/in folderValues-->
</SELECT>
</TD>
</TR>
<TR>
<TD></TD>
<TD>
<BR><INPUT TYPE="SUBMIT" VALUE=" Add ">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE><!--#var title_or_id--></TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#var manage_tabs-->
<!--#if Principia-Session-->
<!--#if expr="_vars['Principia-Session'] != cookie"-->
<h2>Another session is active!</h2>
You cannot start working in this session while another session,
<strong><!--#var Principia-Session--></strong> is active.
Leave <strong><!--#var Principia-Session--></strong> first and then
you may work in this session.
<form action=leave_another>
<input type=submit value="Quit Working in <!--#var Principia-Session-->">
</form>
<!--#else-->
<h2>Active <!--#var title_or_id--> Session Operations</h2>
<form action=leave>
You <strong>are</strong> currently working in the
<!--#var Principia-Session--> session. To
<strong>quit</strong> working in this session click on this button:
<input type=submit value="Quit Working in <!--#var Principia-Session-->">
</form>
<!--#/if-->
<!--#else-->
<h2>Inactive <!--#var title_or_id--> Session Operations</h2>
<form action=enter>
You <strong>are not</strong> currently working in the
<!--#var title_and_id-->
session. To <strong>start</strong> working in this session click
on this button:
<input type=submit value="Start Working in <!--#var title_or_id-->">
</form>
<!--#endif-->
<!--#if nonempty-->
<hr>
<p><form action=save>
You can make work done in <!--#var title_and_id--> permanent by
entering a remark in the space below and then
clicking on the "Save" button.<br>
<textarea name=remark rows=10 cols=50></textarea><br>
<input type=submit value="Save">
</form>
<hr>
<p><form action=discard>
You can throw away work done in <!--#var title_and_id--> by
clicking on the "Discard" button.
<input type=submit value="Discard">
</form>
<!--#endif-->
</body> </html>
<HTML>
<HEAD>
<TITLE>Add Session</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<H2>Add Session</H2>
<FORM ACTION="manage_addSession" METHOD="POST">
<TABLE CELLSPACING="2">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<STRONG>Id</STONG>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="id" SIZE="40">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<EM><STRONG>Title</STRONG></EM>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="title" SIZE="40">
</TD>
</TR>
<TR>
<TD></TD>
<TD>
<BR><INPUT TYPE="SUBMIT" VALUE=" Add ">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Edit</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#var manage_tabs-->
<FORM ACTION="manage_edit" METHOD="POST">
<TABLE CELLSPACING="2">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<STRONG>Id</STRONG>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<!--#var id-->
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<EM><STRONG>Title</STRONG></EM>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="title" SIZE="40" VALUE="<!--#var title-->">
</TD>
</TR>
<TR>
<TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Edit"></TD>
</TR>
</TABLE>
</FORM>
</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