Commit 21b2c409 authored by Jim Fulton's avatar Jim Fulton

initial

parent c41d21d5
from OFS.SimpleItem import Item
import Globals, Acquisition
class Ac_Permissions(Globals.Persistent, Item, Acquisition.Implicit):
"""Provide very simple tabular editing
"""
id='instance____ac_permissions__'
title='Instance Permissions'
meta_type=title
names='Permission name', 'Permission methods'
data=()
manage_options=(
{'label': 'Permissions', 'action': 'manage_main'},
)
icon=''
def __getitem__(self, i): return self.data[i]
def __len__(self): return length(self.data)
manage_main=Globals.HTMLFile('method_select', globals(),
selectops='multiple size=5')
def manage_edit(self, REQUEST, names=[], newname='', newmethods=[]):
" "
data=[]
for i in range(len(names)):
name=names[i]
methods=REQUEST.get('methods%s' % i, None)
if methods: data.append((name, tuple(methods)))
if newname and newmethods:
data.append(newname, tuple(newmethods))
self.data=data
return self.manage_main(self, REQUEST)
from OFS import Folder
import Globals, string, OFS.SimpleItem, Acquisition, AccessControl.Role
from ZPublisher.mapply import mapply
from Manage_Options import Manage_Options
from Ac_Permissions import Ac_Permissions
from ExtensionClass import Base
from App.FactoryDispatcher import FactoryDispatcher
class Item(OFS.SimpleItem.Item,
Globals.Persistent,
Acquisition.Implicit,
AccessControl.Role.RoleManager,
):
"""Basic instances
"""
manage_options=(
{'label':'Security', 'action':'manage_access'},
)
__ac_permissions__=(
('View management screens', ('manage_tabs',)),
('Change permissions', ('manage_access',) ),
)
builtins=(
('OFS.Folder Folder', 'Zope Folder', Folder.Folder),
('OFS.SimpleItem Item', 'Minimal Item', Item),
)
builtin_classes={}
builtin_names={}
for id, name, c in builtins:
builtin_classes[id]=c
builtin_names[id]=name
class PersistentClass(Base):
def __class_init__(self): pass
manage_addZClassForm=Globals.HTMLFile(
'addZClass', globals(), default_class_='OFS.SimpleItem Item')
def manage_addZClass(self, id, title='', base=[], REQUEST=None):
"""Add a Z Class
"""
if not base: base=('OFS.SimpleItem Item',)
bases=[PersistentClass]
for b in base:
if builtin_classes.has_key(b): bases.append(builtin_classes[b])
else: bases.append(getattr(self, b)._zclass_)
bases=tuple(bases)
self._setObject(id, ZClass(id,title,bases))
if REQUEST is not None: return self.manage_main(self,REQUEST)
def manage_subclassableClassNames(self):
r={}
r.update(builtin_names)
while 1:
if not hasattr(self, 'objectItems'): break
for k, v in self.objectItems():
if hasattr(v,'_zclass_') and not r.has_key(k):
r[k]=v.title_and_id()
if not hasattr(self, 'aq_parent'): break
self=self.aq_parent
r=r.items()
r.sort()
return r
class Template:
_p_oid=_p_jar=__module__=None
_p_changed=0
icon=''
class ZClass(Folder.Folder):
"""Zope Class
"""
meta_type="Z Class"
icon=""
instance__meta_type='instance'
instance__icon=''
_properties=({'id':'title', 'type': 'string'},
{'id':'instance__meta_type', 'type': 'string'},
{'id':'instance__icon', 'type': 'string'},
)
_objects=(
{'id': 'instance__manage_options',
'meta_type': Manage_Options.meta_type},
{'id': 'instance____ac_permissions__',
'meta_type': Ac_Permissions.meta_type},
)
manage_main=Globals.HTMLFile('contents', globals())
def all_meta_types(self):
return ZClass.inheritedAttribute('all_meta_types')(self)+(
{'name': 'Instance icon',
'action':'manage_addInstanceIconForm'},
)
def __init__(self, id, title, bases):
self.id=id
self.title=title
dict={}
dict.update(Template.__dict__)
dict['__doc__']=dict['meta_type']=self.instance__meta_type=title or id
self._zclass_=c=type(bases[0])(id, bases, dict)
self.instance__manage_options=c.manage_options=Manage_Options()
self.instance____ac_permissions__=c.__ac_permissions__=Ac_Permissions()
def index_html(self, id, REQUEST):
"""Create Z instance
"""
i=mapply(self._zclass_, (), REQUEST)
if not hasattr(i, 'id'): i.id=id
folder=durl=None
if hasattr(self, 'Destination'):
try:
d=self.Destination
if d.im_self.__class__ is FactoryDispatcher:
folder=d()
durl=self.DestinationURL()
except: pass
if folder is None: folder=self.aq_parent
folder._setObject(id, i)
if REQUEST.has_key('RESPONSE'):
if durl is None: durl=REQUEST['URL2']
REQUEST['RESPONSE'].redirect(durl+'/manage_workspace')
def propertyLabel(self, id):
"""Return a label for the given property id
"""
if id[:10]=='instance__': return id[10:]
return id
def _setProperty(self, id, value, type='string'):
return ZClass.inheritedAttribute('_setProperty')(
self, 'instance__'+id, value, type)
def _setPropValue(self, id, value):
setattr(self,id,value)
z=self._zclass_
setattr(z, id[10:], value)
z._p_changed=1
get_transaction().register(z)
def _delPropValue(self, id):
delattr(self,id)
z=self._zclass_
delattr(z, id[10:])
z._p_changed=1
get_transaction().register(z)
def _setObject(self,id,object,*whatever):
ZClass.inheritedAttribute('_setObject')(self, 'instance__'+id, object)
_reserved=()
def _setOb(self, id, object):
if id in self._reserved:
raise 'Input Error', 'The id %s is reserved' % id
setattr(self, id, object)
z=self._zclass_
setattr(z, id[10:], object)
z._p_changed=1
get_transaction().register(z)
def _delOb(self, id):
delattr(self, id)
z=self._zclass_
delattr(z, id[10:])
z._p_changed=1
get_transaction().register(z)
def all_methods(self):
r={}
for id in self.objectIds():
id=id[10:]
if id in ('manage_options','__ac_permissions__'):
continue
r[id]=1
perms=self._zclass_.inheritedAttribute('__ac_permissions__')
if hasattr(perms,'im_func'): perms=perms.im_func # Waaa
for pname, methods in perms:
for id in methods:
if id: r[id]=1
r=r.keys()
r.sort()
return r
manage_addInstanceIconForm=Globals.HTMLFile('addIcon',globals())
def manage_addInstanceIcon(self, id, title, file, REQUEST):
" "
id=self.manage_addImage(id, file, title)
s=REQUEST['BASE1']
self.manage_changeProperties(
instance__icon=REQUEST['URL1'][len(s)+1:]+'/instance__'+id)
return self.manage_main(self,REQUEST)
def manage_addDTMLMethod(self, id, title='', file='',
REQUEST=None, submit=None):
if not file: file=default_dm_html
return self.inheritedAttribute('manage_addDTMLMethod')(
self, id, title, file, REQUEST, submit)
default_dm_html="""<html>
<head><title><!--#var document_title--></title></head>
<body bgcolor="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#var manage_tabs-->
<P>This is the <!--#var document_id--> Document in
the <!--#var title_and_id--> Folder.</P>
</body></html>
"""
from OFS.SimpleItem import Item
import Globals, Acquisition
class Manage_Options(Globals.Persistent, Item, Acquisition.Implicit):
"""Provide very simple tabular editing
"""
id='instance__manage_options'
title='Instance view definitions'
meta_type=title
names='Permission name', 'Permission methods'
data=()
ddata=()
manage_options=(
{'label': 'Options', 'action': 'manage_main'},
)
icon=''
def __getitem__(self, i): return self.ddata[i]
def __len__(self): return len(self.data)
manage_main=Globals.HTMLFile('method_select', globals(),
selectops='')
def manage_edit(self, REQUEST, names=[], newname='', newmethods=[]):
" "
data=[]
for i in range(len(names)):
name=names[i]
methods=REQUEST.get('methods%s' % i, None)
if methods: data.append((name, tuple(methods)))
if newname and newmethods:
data.append((newname, tuple(newmethods)))
self.data=data
__traceback_info__=data
self.ddata=map(lambda i:
{'label': i[0], 'action': i[1][0]},
data)
return self.manage_main(self, REQUEST)
......@@ -14,48 +14,33 @@ needed by a product and to define product meta data.
This sample product publishes a folder-ish and a simple object.
$Id: __init__.py,v 1.1 1998/11/24 01:23:26 jim Exp $'''
__version__='$Revision: 1.1 $'[11:-2]
$Id: __init__.py,v 1.2 1999/02/22 20:50:02 jim Exp $'''
__version__='$Revision: 1.2 $'[11:-2]
from ImageFile import ImageFile
import Ozome
import Class
# Names of objects added by this product:
meta_types=(
{'name': Ozome.Ozome.meta_type,
'action': 'manage_addOzomeForm', # The method to add one.
},
{'name': Class.ZClass.meta_type,
'action':'manage_addZClassForm'},
)
# Attributes (usually "methods") to be added to folders to support
# creating objects:
methods={
'manage_addOzomeForm': Ozome.manage_addOzomeForm,
'manage_addOzome': Ozome.manage_addOzome,
'manage_addZClassForm': Class.manage_addZClassForm,
'manage_addZClass': Class.manage_addZClass,
'manage_subclassableClassNames': Class.manage_subclassableClassNames,
}
# Permission to be added to folders:
__ac_permissions__=(
# To add items:
('Add Principia Class',
('manage_addOzomeForm', 'manage_addOzome')),
('Add Zope Class',
('manage_addZClassForm', 'manage_addZClass',
'manage_subclassableClassNames')),
)
##############################################################################
#
# $Log: __init__.py,v $
# Revision 1.1 1998/11/24 01:23:26 jim
# initial
#
# Revision 1.3 1998/06/25 11:39:15 jim
# Added permissions.
#
# Revision 1.2 1998/01/02 18:39:01 jim
# initial
#
# Revision 1.1 1997/12/31 21:57:01 jim
# initial
#
#
misc_={}
<HTML>
<HEAD>
<TITLE>Add Icon</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<H2>Add Instance Icon</H2>
<p>
Instance Icons are displayed with images in management interfaces.
Select an image file from your local computer by clicking the
<em>Browse</em> button. The image you select will be uploaded
to the class for use by instances.
</p>
<p>
The instance icon property will be set to give a path to the image.
The path will be based on the current location of this class and
will need to be adjusted if the class is moved.
</p>
<FORM ACTION="manage_addInstanceIcon" METHOD="POST"
ENCTYPE="multipart/form-data">
<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 ALIGN="LEFT" VALIGN="TOP">
<STRONG>Icon image</STRONG>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="file" NAME="file" SIZE="25" VALUE="">
</TD>
</TR>
<TR>
<TD></TD>
<TD>
<BR><INPUT TYPE="SUBMIT" VALUE=" Add ">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Add ZClass</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<H2>Add ZClass</H2>
<FORM ACTION="manage_addZClass" 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"><EM>Title</EM></TH>
<TD ALIGN="LEFT" VALIGN="TOP"><INPUT TYPE="TEXT" NAME="title" SIZE="40"></TD>
</TR>
<TR>
<TH ALIGN="LEFT" VALIGN="TOP"><EM>Base Class</EM></TH>
<TD ALIGN="LEFT" VALIGN="TOP">
<SELECT NAME="base:list">
<!--#in manage_subclassableClassNames-->
<OPTION VALUE="<!--#var sequence-key-->"
<!--#if "_['sequence-key'] == default_class_"-->SELECTED
<!--#/if-->
><!--#var sequence-item--></OPTION>
<!--#/in-->
</SELECT>
</TD>
</TR>
<TR><TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE=" Add "></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Contents</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#var manage_tabs-->
<P>
<!--#if Principia-Session-->
<EM>You are currently working in session <!--#var Principia-Session--></EM>
<P>
<!--#/if Principia-Session-->
<FORM ACTION="." METHOD="POST">
<!--#if objectItems-->
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2">
<!--#in objectItems sort-->
<TR>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="16">
<INPUT TYPE="CHECKBOX" NAME="ids:list" VALUE="<!--#var sequence-key-->">
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<!--#if icon-->
<A HREF="<!--#var sequence-key-->/manage_workspace">
<IMG SRC="<!--#var SCRIPT_NAME-->/<!--#var icon-->"
ALT="[<!--#var meta_type-->]" BORDER="0"></A>
<!--#/if icon-->
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<A HREF="<!--#var sequence-key-->/manage_workspace">
<!--#if "_['sequence-key'][:10]=='instance__'"-->
<!--#var "_['sequence-key'][10:]"-->
<!--#else --><!--#var sequence-key-->
<!--#/if-->
<!--#if title-->(<!--#var title-->)<!--#/if-->
</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-->
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING=2>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="16"></TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="SUBMIT" NAME="manage_renameForm:method" VALUE="Rename">
<INPUT TYPE="SUBMIT" NAME="manage_cutObjects:method" VALUE="Cut">
<INPUT TYPE="SUBMIT" NAME="manage_copyObjects:method" VALUE="Copy">
<!--#if cb_dataValid-->
<INPUT TYPE="SUBMIT" NAME="manage_pasteObjects:method" VALUE="Paste">
<!--#/if-->
<INPUT TYPE="SUBMIT" NAME="manage_delObjects:method" VALUE="Delete">
<INPUT TYPE="SUBMIT" NAME="manage_importExportForm:method" VALUE="Export...">
</TD>
</TR>
</TABLE>
<!--#else-->
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2">
<TR>
<TD>
There are currently no items in <EM><!--#var title_or_id--></EM>
<P>
<!--#if cb_dataValid-->
<INPUT TYPE="SUBMIT" NAME="manage_pasteObjects:method" VALUE="Paste">
<!--#/if-->
</TD>
</TABLE>
<!--#/if-->
</FORM>
<TABLE>
<TR>
<TD VALIGN="TOP">
To add a new item, select an item type and click &quot;Add&quot;.
</TD>
<TD VALIGN="TOP">
<FORM ACTION="." METHOD="GET">
<SELECT NAME=":method">
<!--#in all_meta_types mapping-->
<OPTION value="<!--#var action-->"><!--#var name-->
<!--#/in all_meta_types-->
</SELECT><BR>
<INPUT TYPE="SUBMIT" VALUE=" Add ">
</FORM>
</TD>
</TR>
</TABLE>
<!--#if update_menu-->
<SCRIPT LANGUAGE="javascript">
<!--
window.parent.update_menu();
//-->
</SCRIPT>
<!--#/if-->
</BODY>
</HTML>
<html><head><title><!--#var title_or_id--></title></head>
<body bgcolor="#FFFFFF" link="#000099" vlink="#555555">
<!--#var manage_tabs-->
<form action="manage_edit">
<table>
<!--#in data-->
<tr>
<th align=left valign=top>
<!--#var sequence-key-->
<input type=hidden name="names:list" value="<!--#var sequence-key-->">
</th>
<td align=left valign=top>
<!--#with "_.namespace(methods=_['sequence-item'])"-->
<select name="<!--#var "'methods%s:list' % _['sequence-index']"-->"
<!--#var selectops-->>
<!--#in all_methods-->
<option
<!--#if "_['sequence-item'] in methods"-->SELECTED
<!--#/if-->><!--#var sequence-item--></option>
<!--#/in-->
</select></td>
<!--#/with-->
</tr>
<!--#/in-->
<tr>
<th align=left valign=top>New: <input type=text name="newname" size=20></th>
<td align=left valign=top>
<select name=newmethods:list <!--#var selectops-->>
<!--#in all_methods-->
<option><!--#var sequence-item--></option>
<!--#/in-->
</select></td>
</tr>
<tr><td colspan=2 align=center>
<input type=submit value=" Change "></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