Commit 2abe6e3e authored by Jim Fulton's avatar Jim Fulton

initial

parent f85cacc1
__doc__="""Application management component"""
__version__='$Revision: 1.1 $'[11:-2]
import sys,os,time,Globals
from Acquisition import Acquirer
from Management import Management
from Globals import ManageHTMLFile
class ApplicationManager(Acquirer,Management):
"""Application management component."""
manage_main =ManageHTMLFile('App/appMain')
manage_packForm=ManageHTMLFile('App/pack')
manage_undoForm=ManageHTMLFile('App/undo')
manage_options=(
{'icon':'App/arrow.jpg', 'label':'Application Manager',
'action':'manage_main', 'target':'manage_main'},
{'icon':'App/arrow.jpg', 'label':'Compact Database',
'action':'manage_packForm','target':'manage_main'},
{'icon':'App/arrow.jpg','label':'Undo Changes',
'action':'manage_undoForm','target':'manage_main'},
)
title ='Application Manager'
name ='application manager'
process_id =os.getpid()
process_start=int(time.time())
def parentObject(self):
try: return (self.aq_parent,)
except: return ()
def process_time(self):
s=int(time.time())-self.process_start
d=int(s/86400)
s=s-(d*86400)
h=int(s/3600)
m=int((s-(h*3600))/60)
d=d and ('%s day%s' % (d,(d!=1 and 's' or ''))) or ''
return '%s %02d:%02d' % (d,h,m)
def db(self): return Globals.Bobobase
def db_name(self): return Globals.BobobaseName
def db_size(self):
s=os.stat(self.db_name())[6]
if s >= 1048576.0: return '%.1fM' % (s/1048576.0)
return '%.1fK' % (s/1024.0)
def manage_shutdown(self):
"""Shut down the application"""
sys.exit(0)
def revert_points(self): return ()
"""Common HTML dialog boxes
MessageDialog(title, message, action, [target])
A very simple dialog used to display an HTML page titled title,
displaying message message and an OK button. Clicking the OK
button will take the browser to the URL specified in action.
The *optional* target argument can be used to force a (frames
capable) browser to load the URL specified in action into a specific
frame. (Specifying '_new' will cause the browser to load the
specified URL into a new window, for example).
example usage:
<PRE>
return MessageDialog(title='Just thought you should know...',
message='You have wiped out your data.',
action='/paid_tech_support/prices.html',
target='_top')
</PRE>"""
__version__='$Revision: 1.1 $'[11:-2]
from STPDocumentTemplate import HTML
MessageDialog = HTML("""
<HTML>
<HEAD>
<TITLE><!--#var title--></TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<FORM ACTION="<!--#var action-->" METHOD="GET"
<!--#if target-->
TARGET="<!--#var target-->"
<!--#/if target-->>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="10">
<TR>
<TD VALIGN="TOP">
<BR>
<CENTER><B><FONT SIZE="+6" COLOR="#77003B">!</FONT></B></CENTER>
</TD>
<TD VALIGN="TOP">
<BR><BR>
<CENTER>
<!--#var message-->
</CENTER>
</TD>
</TR>
<TR>
<TD VALIGN="TOP">
</TD>
<TD VALIGN="TOP">
<CENTER>
<INPUT TYPE="SUBMIT" VALUE=" Ok ">
</CENTER>
</TD>
</TR>
</TABLE>
</FORM>
</BODY></HTML>""", target='')
"""Standard management interface support
$Id: Management.py,v 1.1 1997/07/25 19:46:19 jim Exp $"""
__version__='$Revision: 1.1 $'[11:-2]
import sys,Globals
from Dialogs import MessageDialog
from Globals import ManageHTMLFile,admin_groups
class Management:
"""A mix-in class for basic management interface support.
Management provides the basic frames-based management interface for an
object. For any Management derived instance, the url <object>/manage
will return the management interface for that object. The manage
attribute is a document template containing a frameset referencing
two named frames: "manage_menu" on the left, "manage_main" on the
right. The "manage_menu" frame will load the manage_menu attribute
of your instance, The "manage_main" frame will load the instance's
manage_main attribute.
manage_menu -- the management menu frame. This is provided by the
Management class. It renders menu options based on your
instance's manage_options attribute, as described
below.
manage_main -- the "management homepage" frame. This is the default
document loaded into the right-hand frame whenever a
browser goes to <object>/manage. This page will often
be a "status" page, relaying relevant information about
the instance being viewed, as well as a link to the
"public" interface of the object (index_html).
The Management class provides a default document template
that is used for manage_main if the instance does not
override this attribute.
manage_options -- This attribute is a list of dictionaries containing
information about each menu item to be displayed in
the "manage_menu" frame. Subclasses should override the
default manage_options attribute of Management (which is
just an empty list, producing an empty menu).
For each dictionary in the list, a menu item will be shown
with an icon of dict['icon'],
a label of dict['label'],
linking to <PARENT_URL>/dict['action'],
targeted at the frame dict['target'].
If your Management derived class defines a manage_options
attribute:
<PRE>
manage_options=[{'icon':'foo.gif',
'label':'Go to spam',
'action':'spam_html',
'target':'manage_main'}]
</PRE>
...you will get one menu item labelled 'Go to spam',
(with an icon of foo.gif) that is a hyperlink to
<PARENT_URL>/spam_html, and when clicked, the document
will appear in the 'manage_main' frame of the web browser.
If you wanted a new window to appear containing the
document, you would use '_new' as the value of 'target'
in the dictionary for that item.
Following these general rules will keep you from
inadvertantly ending up with nested framesets:
o If your menu option should take the user to another
attribute of the current object, the target should
be 'manage_main'.
o If your menu option should take the user to the public
interface of the current object, the target should be
'_top'.
o If your menu option should take the user to the
management or public interface of another object, the
target should be '_top'.
o If your menu option should cause a new window to be
opened with the requested document, the target should
be '_new' (This is often useful for things like online
help).
A menu item will be generated for each dictionary in the
manage_options list. Sometimes it is useful to provide a
separator between various menu items; to insert a
"separator" line as a menu entry, put an empty dictionary
in your manage_options list where you want the separator
to appear.
"""
manage_options =[]
manage =ManageHTMLFile('App/manage')
manage_menu =ManageHTMLFile('App/menu')
*shared*
# install ApplicationManager.py
# install Dialogs.py
# install Management.py
# install appMain.dtml
# install manage.dtml
# install menu.dtml
# install pack.dtml
# install undo.dtml
# install www www/%(package)s
<HTML>
<HEAD>
<TITLE><!--#var title--></TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B">
<FONT SIZE="+2"><!--#var title--></FONT>
<P>
The application manager allows you to view application status information,
and allows you to perform maintenance tasks such as process control,
database packing, and &quot;undoing&quot; previous changes to your
application's configuration or data.
<P>
<TABLE CELLPADDING="4">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP"><B>Process Id:</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><!--#var process_id--></TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP"><B>Process Uptime:</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><!--#var process_time--></TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP"><B>Database Size:</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><!--#var db_size--></TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<BR>Click &quot;Shutdown&quot; to shutdown the application..
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<FORM ACTION="<!--#var PARENT_URL-->/manage_shutdown"
METHOD="POST" TARGET="_top">
<BR><INPUT TYPE="SUBMIT" VALUE=" Shutdown ">
</FORM>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE><!--#var name--></TITLE>
</HEAD>
<FRAMESET FRAMEBORDER="NO" BORDER="0" FRAMESPACING="0" COLS="140,*">
<FRAME SRC="<!--#var PARENT_URL-->/manage_menu" NAME="manage_menu"
MARGINWIDTH="6" MARGINHEIGHT="6" SCROLLING="auto">
<FRAME SRC="<!--#var PARENT_URL-->/manage_main" NAME="manage_main"
MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="auto">
</FRAMESET>
<NOFRAMES>
Management interfaces require the use of a <B>frames-capable</B> web browser, such as:
<UL>
<LI> <B><A HREF="http://www.netscape.com">Netscape Navigator 3.0</A></B>
<LI> <B><A HREF="http://www.microsoft.com">Microsoft Internet Explorer 3.0</A></B>
</UL>
</NOFRAMES>
</HTML>
<HTML>
<HEAD>
<TITLE>Management Menu</TITLE>
</HEAD>
<BODY BACKGROUND="<!--#var SOFTWARE_URL-->/App/background.jpg"
BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B">
<TABLE BORDER="0" WIDTH="100">
<TR>
<TD ALIGN="LEFT" COLSPAN="2" VALIGN="TOP">
<IMG SRC="<!--#var SOFTWARE_URL-->/logo.jpg"
WIDTH="90" HEIGHT="90">
<BR>
</TD>
</TR>
<TR><TD></TD><TD></TD></TR>
<!--#if manage_options-->
<!--#in manage_options mapping-->
<!--#if sequence-item-->
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<A HREF="<!--#var PARENT_URL-->/<!--#var action-->"
TARGET="<!--#var target-->"><IMG BORDER="0" HEIGHT="16"
WIDTH="16" ALT="<!--#var label-->"
SRC="<!--#var SOFTWARE_URL-->/<!--#var icon-->"></A>
</TD>
<TD ALIGN="LEFT">
<FONT SIZE="-1">
<A HREF="<!--#var PARENT_URL-->/<!--#var action-->"
TARGET="<!--#var target-->">
<!--#var label-->
</A></FONT>
</TD>
</TR>
<!--#else sequence-item-->
<TR><TD COLSPAN="2"><HR></TD></TR>
<!--#/if sequence-item-->
<!--#/in manage_options-->
<!--#/if manage_options-->
</TABLE>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE><!--#var title--></TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B">
<FONT SIZE="+2">Compact Database</FONT>
<P>
<FORM ACTION="<!--#var PARENT_URL-->/manage_pack" METHOD="POST">
<TABLE CELLPADDING="4">
<TR>
<TD VALIGN="TOP" COLSPAN="2">
The transactional nature of this application causes multiple versions of
certain types of data to be stored in it's database. While this system
allows powerful error recovery abilities, over time this data can take
up a lot of disk space, so you should occasionally compact the database.
<P>
Compacting the database makes it smaller by removing &quot;snapshots&quot;
of the application's state which are older than the date you select from
the list below. You can also select &quot;Remove all old revisions&quot;,
which will make the database as small as possible and remove all old
revisions from the database.
</TD>
</TR>
<TR>
<!--#if revert_points-->
<TD ALIGN="LEFT" VALIGN="TOP"><B>Remove revisions older than:</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<SELECT NAME="start_time" SIZE="5">
<OPTION VALUE="">Remove all old revisions</OPTION>
<!--#in revert_points-->
<OPTION><!--#var sequence-item--></OPTION>
<!--#/in revert_points-->
</SELECT><BR>
<INPUT TYPE="SUBMIT" VALUE=" Compact Database ">
</TD>
<!--#else revert_points-->
<TD COLSPAN="2">
<I>No old revisions currently exist in the database.</I>
</TD>
<!--#/if revert_points-->
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE><!--#var title--></TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B">
<FONT SIZE="+2">Undo Changes</FONT>
<P>
<FORM ACTION="<!--#var PARENT_URL-->/manage_undo" METHOD="POST">
<TABLE CELLPADDING="4">
<TR>
<TD COLSPAN="2">
This application's trasactional features allow you to easily undo changes
made to the application's settings or data. You can revert the application
to a &quot;snapshot&quot; of it's state at a previous point in time.
</TD>
</TR>
<TR>
<!--#if revert_points-->
<TD ALIGN="LEFT" VALIGN="TOP"><B>Revert database to date/time:</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<SELECT NAME="start_time" SIZE="5">
<!--#in revert_points-->
<OPTION><!--#var sequence-item--></OPTION>
<!--#/in revert_points-->
</SELECT><BR>
<INPUT TYPE="SUBMIT" VALUE=" Revert Database ">
</TD>
<!--#else revert_points-->
<TD COLSPAN="2">
<I>No old revisions currently exist in the database.</I>
</TD>
<!--#/if revert_points-->
</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