Commit 14cbd55e authored by Jim Fulton's avatar Jim Fulton

new folderish control panel and product management

parent f400850a
#!/bin/env python
##############################################################################
#
# Copyright
#
# Copyright 1998 Digital Creations, Inc., 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
# rights reserved.
#
##############################################################################
__doc__='''Standard routines for handling Principia Extensions
Principia extensions currently include external methods and pluggable brains.
$Id: Extensions.py,v 1.1 1998/08/03 13:43:26 jim Exp $'''
__version__='$Revision: 1.1 $'[11:-2]
from string import find
import os, zlib, rotor
path_split=os.path.split
exists=os.path.exists
class FuncCode:
def __init__(self, f, im=0):
self.co_varnames=f.func_code.co_varnames[im:]
self.co_argcount=f.func_code.co_argcount-im
def __cmp__(self,other):
return cmp((self.co_argcount, self.co_varnames),
(other.co_argcount, other.co_varnames))
def getObject(module, name, reload=0, modules={}):
if modules.has_key(module):
old=modules[module]
if old.has_key(name) and not reload: return old[name]
else:
old=None
d,n = path_split(module)
if d: raise ValueError, (
'The file name, %s, should be a simple file name' % module)
m={}
d=find(n,'.')
if d > 0:
d,n=n[:d],n[d+1:]
n=("%s/lib/python/Products/%s/Extensions/%s.pyp"
% (SOFTWARE_HOME,d,n))
__traceback_info__=n, module
if exists(n):
data=zlib.decompress(
rotor.newrotor(d+' shshsh').decrypt(open(n).read())
)
exec compile(data,module,'exec') in m
else:
exec open("%s/Extensions/%s.py" %
(SOFTWARE_HOME, module)) in m
else:
exec open("%s/Extensions/%s.py" % (SOFTWARE_HOME, module)) in m
r=m[name]
if old:
for k, v in m.items(): old[k]=v
else: modules[module]=m
return r
class NoBrains: pass
def getBrain(module, class_name, reload=0):
'Check/load a class'
if not module and not class_name: return NoBrains
try: c=getObject(module, class_name, reload)
except KeyError, v:
if v == class_name: raise ValueError, (
'The class, %s, is not defined in file, %s' % (class_name, module))
if not hasattr(c,'__bases__'): raise ValueError, (
'%s, is not a class' % class_name)
return c
##############################################################################
#
# $Log: Extensions.py,v $
# Revision 1.1 1998/08/03 13:43:26 jim
# new folderish control panel and product management
#
#
#!/bin/env python
##############################################################################
#
# Copyright
#
# Copyright 1998 Digital Creations, Inc., 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
# rights reserved.
#
##############################################################################
__doc__='''Principia Factories
$Id: Factory.py,v 1.1 1998/08/03 13:43:27 jim Exp $'''
__version__='$Revision: 1.1 $'[11:-2]
import OFS.SimpleItem, Acquisition, Globals
class Factory(OFS.SimpleItem.Item, Acquisition.Implicit):
"Model factory meta-data"
meta_type='Principia Factory'
icon='p_/Factory_icon'
manage_options=(
{'label':'Edit', 'action':'manage_main'},
{'label':'Security', 'action':'manage_access'},
)
def __init__(self, id, title, object_type, initial, product):
self.id=id
self.title=title
self.object_type=object_type
self.initial=initial
self.__of__(product)._register()
def _notifyOfCopyTo(self, container):
if container.__class__ is not Product:
raise TypeError, (
'Factories can only be copied to <b>products</b>.')
def _postCopy(self, container):
self._register()
def _register(self):
# Register with the product folder
product=self.aq_parent
product.aq_acquire('_manage_add_product_meta_type')(
product, self.id, self.object_type)
def _unregister(self):
# Unregister with the product folder
product=self.aq_parent
product.aq_acquire('_manage_remove_product_meta_type')(
product, self.id, self.object_type)
manage_main=Globals.HTMLFile('editFactory',globals())
def index_html(self, REQUEST):
" "
return getattr(self, self.initial)(self.aq_parent, REQUEST)
##############################################################################
#
# $Log: Factory.py,v $
# Revision 1.1 1998/08/03 13:43:27 jim
# new folderish control panel and product management
#
#
# Implement the manage_addProduct method of object managers
import Acquisition
from string import rfind
class ProductDispatcher(Acquisition.Implicit):
" "
def __bobo_traverse__(self, REQUEST, name):
product=self.aq_acquire('_getProducts')()._product(name)
dispatcher=FactoryDispatcher(product, self.aq_parent, REQUEST)
return dispatcher.__of__(self)
class FactoryDispatcher(Acquisition.Implicit):
" "
def __init__(self, product, dest, REQUEST):
self._product=product.__dict__
self._d=dest
v=REQUEST['URL']
v=v[:rfind(v,'/')]
self._u=v[:rfind(v,'/')]
def Destination(self):
"Return the destination for factory output"
return self._d
Destination__roles__=None
def DestinationURL(self):
"Return the URL for the destination for factory output"
return self._u
DestinationURL__roles__=None
def __getattr__(self, name):
d=self._product
if d.has_key(name): return d[name].__of__(self)
raise AttributeError, name
This diff is collapsed.
# Product registry and new product factory model. There will be a new
# mechanism for defining actions for meta types. If an action is of
# the form:
#
# manage_addProduct-name-factoryid
#
# Then the machinery that invokes an add-product form
# will return:
# ....what?
from OFS.Folder import Folder
class ProductRegistry:
# This class implements a protocol for registering products that
# are defined through the web. It also provides methods for
# getting hold of the Product Registry, Control_Panel.Products.
# This class is a mix-in class for the top-level application object.
def _getProducts(self): return self.Control_Panel.Products
_product_meta_types=()
def _manage_remove_product_meta_type(self, product, id, meta_type):
self._product_meta_types=filter(lambda mt, nmt=meta_type:
mt['name']!=nmt,
self._product_meta_types)
def _manage_add_product_meta_type(self, product, id, meta_type):
if filter(lambda mt, nmt=meta_type:
mt['name']==nmt,
self.all_meta_types()):
raise 'Type Exists', (
'The type <em>%s</em> is already defined.')
self._product_meta_types=self._product_meta_types+({
'name': meta_type,
'action': ('manage_addProduct/%s/%s' % (product.id, id)),
},)
<html><head><title>Create a factory</title></head>
<body bgcolor="#FFFFFF" link="#000099" vlink="#555555" alink="#77003B">
<h2>Create an object factory</h2>
<!--#if objectIds-->
<form action="manage_addPrincipiaFactory" method="POST">
<table cellspacing="2">
<tr>
<th align="LEFT" valign="TOP">Id</th>
<td align="LEFT" valign="TOP"><input type="TEXT" name="id"
size="40"></td>
</tr>
<tr>
<th align="LEFT" valign="TOP">Title</th>
<td align="LEFT" valign="TOP"><input type="TEXT" name="title"
size="40"></td>
</tr>
<tr>
<th align="LEFT" valign="TOP">Add list name</th>
<td align="LEFT" valign="TOP"><input type="TEXT" name="object_type"
size="40"></td>
</tr>
<tr><th ALIGN="LEFT">Method</th>
<td ALIGN="LEFT"><select name="initial">
<!--#in objectItems-->
<!--#if "meta_type != 'Principia Factory'"-->
<option><!--#var sequence-key--></option>
<!--#/if-->
<!--#/in-->
</select></td></tr>
<tr><td></td><td><br><input type="SUBMIT" value="Generate"></td></tr>
</table></form>
The <strong>Method</strong> is the method that will be invoked when a
user adds a new object. This must be one of the objects in the
product, typically a Document.
<!--#else-->
Before you can define a factory, you have to define one or more "methods",
such as Document or other objects that do the factory's work.
<!--#/if-->
</body></html>
<html><head><title>Create a product</title></head>
<body bgcolor="#FFFFFF" link="#000099" vlink="#555555" alink="#77003B">
<h2>Create a Product</h2>
<form action="manage_addProduct" method="POST">
<table cellspacing="2">
<tr>
<th align="LEFT" valign="TOP">Id</th>
<td align="LEFT" valign="TOP"><input type="TEXT" name="id"
size="40"></td>
</tr>
<tr>
<th align="LEFT" valign="TOP">Title</th>
<td align="LEFT" valign="TOP">
<input type="TEXT" name="title" size="40">
</td>
</tr>
<tr><td></td><td><br><input type="submit" value="Generate"></td></tr>
</table></form>
</body></html>
<HTML>
<HEAD>
<TITLE>Cache</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#var manage_tabs-->
<h2>Manual Cache Garbage Collection</h2><P>
<table>
<tr><td>
<strong>Full Sweep</strong><br>
Make a single pass through the cache, removing any objects that are no
longer referenced, and deactivating objects that have not been
accessed in the number of seconds given in the input box to the right
of this text.
</td><td>
<form action="<!--#var URL1-->/manage_full_sweep" method=GET>
<input type="text" name="value:int" value="<!--#var cache_age-->" size=6><br>
<input type="submit" value="Full Sweep">
</form></td></tr>
<tr><td>
<strong>Minimize</strong><br>
Make multiple passes through the cache, removing any objects that are no
longer referenced, and deactivating objects that have not been
accessed in the number of seconds given in the input box to the right
of this text.
</td><td>
<form action="<!--#var URL1-->/manage_minimize" method=GET>
<input type="text" name="value:int" value="<!--#var cache_age-->" size=6><br>
<input type="submit" value="Minimize">
</form></td></tr>
</table
<h3>Cache Statistics</h3>
<table>
<tr><th align=right>Total number of objects in the database:</th>
<td><!--#var database_size--></td></tr>
<tr><th align=right>Number of objects in the cache:</th>
<td><!--#var cache_length--></td></tr>
<tr><th align=right>Mean time since last access:</th>
<td><!--#var cache_mean_age--></td></tr>
<tr><th align=right>Deactivation rate (objects/second):</th>
<td><!--#var cache_mean_deac--></td></tr>
<tr><th align=right>Deallocation rate (objects/second):</th>
<td><!--#var cache_mean_deal--></td></tr>
<tr><th align=right>Time of last cache garbage collection:</th>
<td><!--#var cache_last_gc_time--></td></tr>
</table>
<!--#if show_cache_detail-->
<h4>Cache Details</h4><P>
<table border><tr><th>Object Class</th><th>Count</th></tr>
<!--#in cache_detail-->
<tr><td><!--#var sequence-key--></td><td><!--#var sequence-item--></td></tr>
<!--#/in-->
</table>
<!--#/if-->
<!--#if show_cache_extreme_detail-->
<h4>Objects in the cache</h4><P>
<table border><tr><th>Object ID</th>
<th>Object Class</th>
<th>Reference Count</th>
<th>References</th>
</tr>
<!--#in cache_extreme_detail mapping-->
<tr><td><!--#var oid--></td>
<td><!--#var klass--></td>
<td><!--#var rc--></td>
<td><!--#var references--></td>
</tr>
<!--#/in-->
</table>
<!--#/if-->
</BODY></HTML>
<HTML>
<HEAD>
<TITLE>Cache</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#var manage_tabs-->
<h2>Cache Parameters and Statistics</h2>
<table>
<tr><th align=right>Total number of objects in the database:</th>
<td><!--#var database_size--></td></tr>
<tr><th align=right>Number of objects in the cache:</th>
<td><!--#var cache_length--></td></tr>
<tr><th valign=top align=right>Target size:</th><td>
<form action="<!--#var URL1-->/manage_cache_size" method=GET>
<input type="text" name="value:int" value="<!--#var cache_size-->" size=6>
<input type="submit" value="Change">
</form></td></tr>
<tr><th align=right>Mean time since last access:</th>
<td><!--#var cache_mean_age--></td></tr>
<tr><th valign=top align=right>Target maximum time between accesses:</th><td>
<form action="<!--#var URL1-->/manage_cache_age" method=GET>
<input type="text" name="value:int" value="<!--#var cache_age-->" size=6>
<input type="submit" value="Change">
</form></td></tr>
<tr><th align=right>Deactivation rate (objects/second):</th>
<td><!--#var cache_mean_deac--></td></tr>
<tr><th align=right>Deallocation rate (objects/second):</th>
<td><!--#var cache_mean_deal--></td></tr>
<tr><th align=right>Time of last cache garbage collection:</th>
<td><!--#var cache_last_gc_time--></td></tr>
</table>
<!--#if show_cache_detail-->
<h4>Cache Details</h4><P>
<table border><tr><th>Object Class</th><th>Count</th></tr>
<!--#in cache_detail-->
<tr><td><!--#var sequence-key--></td><td><!--#var sequence-item--></td></tr>
<!--#/in-->
</table>
<!--#/if-->
<!--#if show_cache_extreme_detail-->
<h4>Objects in the cache</h4><P>
<table border><tr><th>Object ID</th>
<th>Object Class</th>
<th>Reference Count</th>
<th>References</th>
</tr>
<!--#in cache_extreme_detail mapping-->
<tr><td><!--#var oid--></td>
<td><!--#var klass--></td>
<td><!--#var rc--></td>
<td><!--#var references--></td>
</tr>
<!--#/in-->
</table>
<!--#/if-->
</BODY></HTML>
<HTML>
<HEAD>
<TITLE>Contents</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#var manage_tabs-->
<FORM ACTION="manage_shutdown" METHOD="POST" TARGET="_top">
The Control Panel provides access to system management functions,
such as database and product management. The system has been running
(with a process ID of <!--#var process_id-->) for <!--#var
process_time-->. Click &quot;Shutdown&quot; to shutdown the Principia
process. It will be restarted on the next web request.
<BR><INPUT TYPE="SUBMIT" VALUE="Shutdown">
</FORM>
<!--#if Principia-Session-->
<EM>You are currently working in session <!--#var Principia-Session--></EM>
<!--#/if Principia-Session-->
<P>
<TABLE>
<!--#in objectItems-->
<TR>
<td> </td>
<TD ALIGN="LEFT" VALIGN="TOP">
<A HREF="<!--#var sequence-key-->/manage_main">
<IMG SRC="<!--#var SCRIPT_NAME-->/<!--#var icon-->"
ALT="Click to open this item" BORDER="0"></A>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<A HREF="<!--#var sequence-key-->/manage_main">
<!--#var title-->
</A>
<!--#if locked_in_session-->
<!--#if modified_in_session-->
<IMG SRC="<!--#var SCRIPT_NAME-->/p_/locked"
ALT="This item has been modified in this session">
<!--#else-->
<IMG SRC="<!--#var SCRIPT_NAME-->/p_/lockedo"
ALT="This item has been modified in another session">
<!--#/if-->
<!--#/if-->
</TD>
</TR>
<!--#/in objectValues-->
</TABLE>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE><!--#var title--></TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#var manage_tabs-->
<P>
The Database Manager allows you to view database status information.
It also allows you to perform maintenance tasks such as
database packing, cache management,
and &quot;undoing&quot; previous changes to your site.
<P>
<TABLE CELLPADDING="4" BORDER="1">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<STRONG>Database Size</STRONG>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<!--#var db_size-->
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<STRONG>Database Location</STRONG>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<font size="-1"><!--#var db_name--></font>
</TD>
</TR>
</TABLE>
<TABLE CELLPADDING="4">
<TR>
<FORM ACTION="manage_pack" METHOD="POST" TARGET="manage_main">
<TD ALIGN="LEFT" VALIGN="TOP">
<BR>Click &quot;Pack&quot; to pack the Principia database, removing
previous revisions of objects that are older than
<INPUT TYPE="TEXT" VALUE="0" NAME="days:float" SIZE="3"> days.
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<BR><INPUT TYPE="SUBMIT" VALUE=" Pack ">
</TD>
</FORM>
</TR>
</TABLE>
</BODY>
</HTML>
<html><head>
<title>Create a Distribution Archive</title>
</head><body>
<!--#var manage_tabs-->
<H2>Create a Distribution Archive</H2>
<form action="manage_distribute"><table>
<tr><th align="LEFT" valign="TOP">Version</th>
<td align="LEFT" valign="TOP">
<input type=text name="version" value="<!--#var new_version-->">
</td>
</tr>
<tr><th align="LEFT" valign="TOP">Configurable objects</th>
<td align="LEFT" valign="TOP">
<select name="configurable_objects:list" size=10 multiple>
<!--#in objectItems-->
<option value="<!--#var sequence-key-->" <!--#
if "_['sequence-key'] in configurable_objects_"
-->SELECTED<!--#/if-->><!--#
var title_and_id--></option>
<!--#/in-->
</select>
</td>
</tr>
<tr><th></th>
<td align="LEFT" valign="TOP">
<input type=submit value="Create a distribution archive"
</td>
</tr>
</table></form>
</body></html>
<html><head><title>Change a factory</title></head>
<body bgcolor="#FFFFFF" link="#000099" vlink="#555555" alink="#77003B">
<!--#var manage_tabs-->
<form action="manage_edit" method="POST">
<table cellspacing="2">
<tr>
<th align="LEFT" valign="TOP">Id</th>
<td align="LEFT" valign="TOP"><!--#var id--></td>
</tr>
<tr>
<th align="LEFT" valign="TOP">Title</th>
<td align="LEFT" valign="TOP"><input type="TEXT" name="title"
size="40" value="<!--#var title-->"></td>
</tr>
<tr>
<th align="LEFT" valign="TOP">
Name of new object type, which is the name that will appear in
the folder "add" list
</th>
<td align="LEFT" valign="TOP"><input type="TEXT" name="object_type"
size="40" value="<!--#var object_type-->"></td>
</tr>
<tr><th ALIGN="LEFT">
Select a method to begin the process of adding
new objects. This is the method that will be invoked when a
user adds a new object.
</th>
<td ALIGN="LEFT"><select name="initial">
<!--#in objectIds-->
<option
<!--#if expr="_['sequence-item']==initial"-->SELECTED<!--#/if-->
><!--#var sequence-item--></option>
<!--#/in-->
</select></td></tr>
<tr><td></td><td><br><input type="SUBMIT" value="Change"></td></tr>
</table></form>
</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__='''Simple module for writing tar files
$Id: tar.py,v 1.1 1998/08/03 13:43:28 jim Exp $'''
__version__='$Revision: 1.1 $'[11:-2]
import sys, time, zlib
try:
from newstruct import pack
except:
from struct import pack
from string import find, join
def oct8(i):
i=oct(i)
return '0'*(6-len(i))+i+' \0'
def oct12(i):
i=oct(i)
return '0'*(11-len(i))+i+' '
def pad(s,l):
ls=len(s)
if ls >= l: raise ValueError, 'value, %s, too wide for field (%d)' % (s,l)
return s+'\0'*(l-ls)
class TarEntry:
def __init__(self, path, data,
mode=0644, uid=0, gid=0, mtime=None, typeflag='0',
linkname='', uname='jim', gname='system', prefix=''):
"Initialize a Tar archive entry"
self.data=data
if mtime is None: mtime=int(time.time())
header=join([
pad(path, 100),
oct8(mode),
oct8(uid),
oct8(gid),
oct12(len(data)),
oct12(mtime),
' ' * 8,
typeflag,
pad(linkname, 100),
'ustar\0',
'00',
pad(uname, 32),
pad(gname, 32),
'000000 \0',
'000000 \0',
pad(prefix, 155),
'\0'*12,
], '')
if len(header) != 512: raise 'Bad Header Length', len(header)
header=(header[:148]+
oct8(reduce(lambda a,b: a+b, map(ord,header)))+
header[156:])
self.header=header
def __str__(self):
data=self.data
l=len(data)
if l%512: data=data+'\0'*(512-l%512)
return self.header+data
def tar(entries):
r=[]
ra=r.append
for name, data in entries:
ra(str(TarEntry(name,data)))
ra('\0'*1024)
return join(r,'')
def tgz(entries):
c=zlib.compressobj()
compress=c.compress
r=[]
ra=r.append
for name, data in entries:
ra(compress(str(TarEntry(name,data))))
ra(compress('\0'*1024))
ra(c.flush())
return join(r,'')
class tgzarchive:
def __init__(self, name, time=None):
self._f=gzFile('%s.tar' % name, time)
def add(self, name, data):
self._f.write(str(TarEntry(name,data)))
def finish(self):
self._f.write('\0'*1024)
def __str__(self):
return self._f.getdata()
class gzFile:
_l=0
_crc=zlib.crc32("")
def __init__(self, name, t=None):
self._c=zlib.compressobj(9, zlib.DEFLATED, -zlib.MAX_WBITS,
zlib.DEF_MEM_LEVEL, 0)
if t is None: t=time.time()
self._r=['\037\213\010\010',
pack("<i", int(t)),
'\2\377',
name,
'\0'
]
def write(self, s):
self._crc=zlib.crc32(s, self._crc)
self._r.append(self._c.compress(s))
self._l=self._l+len(s)
def getdata(self):
r=self._r
append=r.append
append(self._c.flush())
append(pack("<i", self._crc))
append(pack("<i", self._l))
return join(r,'')
##############################################################################
#
# $Log: tar.py,v $
# Revision 1.1 1998/08/03 13:43:28 jim
# new folderish control panel and product management
#
#
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