Commit 4290b8a3 authored by Jim Fulton's avatar Jim Fulton

Added SimpleItem mix-in and new title/id methods.

parent 172bed30
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
__doc__='''Application support __doc__='''Application support
$Id: Application.py,v 1.9 1997/09/09 14:21:07 brian Exp $''' $Id: Application.py,v 1.10 1997/09/10 18:42:35 jim Exp $'''
__version__='$Revision: 1.9 $'[11:-2] __version__='$Revision: 1.10 $'[11:-2]
import Globals,Folder,regex import Globals,Folder,regex
...@@ -48,7 +48,7 @@ class Application(Folder.Folder): ...@@ -48,7 +48,7 @@ class Application(Folder.Folder):
raise 'Redirect', ("%s/%s" % (PARENT_URL, destination)) raise 'Redirect', ("%s/%s" % (PARENT_URL, destination))
__allow_groups__=UserFolder() __allow_groups__=UserFolder()
def open_bobobase(): def open_bobobase():
# Open the application database # Open the application database
...@@ -145,6 +145,9 @@ if __name__ == "__main__": main() ...@@ -145,6 +145,9 @@ if __name__ == "__main__": main()
############################################################################## ##############################################################################
# #
# $Log: Application.py,v $ # $Log: Application.py,v $
# Revision 1.10 1997/09/10 18:42:35 jim
# Added SimpleItem mix-in and new title/id methods.
#
# Revision 1.9 1997/09/09 14:21:07 brian # Revision 1.9 1997/09/09 14:21:07 brian
# Fixed Image editing # Fixed Image editing
# #
......
"""Document object""" """Document object"""
__version__='$Revision: 1.13 $'[11:-2] __version__='$Revision: 1.14 $'[11:-2]
from Globals import HTML from Globals import HTML
from Globals import HTMLFile from Globals import HTMLFile
from string import join, split, strip, rfind from string import join, split, strip, rfind
from AccessControl.Role import RoleManager from AccessControl.Role import RoleManager
import regex import regex
import SimpleItem
class Document(HTML, RoleManager, SimpleItem.Item_w__name__):
class Document(HTML, RoleManager):
"""A Document object""" """A Document object"""
meta_type ='Document' meta_type ='Document'
title=''
icon ='OFS/Document_icon.gif' icon ='OFS/Document_icon.gif'
__state_names__=HTML.__state_names__+('title','__roles__') __state_names__=HTML.__state_names__+('title','__roles__')
......
"""Folder object """Folder object
$Id: Folder.py,v 1.8 1997/08/29 18:39:31 brian Exp $""" $Id: Folder.py,v 1.9 1997/09/10 18:42:36 jim Exp $"""
__version__='$Revision: 1.8 $'[11:-2] __version__='$Revision: 1.9 $'[11:-2]
from Globals import HTMLFile from Globals import HTMLFile
...@@ -12,6 +12,7 @@ from Image import ImageHandler ...@@ -12,6 +12,7 @@ from Image import ImageHandler
from Document import DocumentHandler from Document import DocumentHandler
from AccessControl.User import UserFolderHandler from AccessControl.User import UserFolderHandler
from AccessControl.Role import RoleManager from AccessControl.Role import RoleManager
import SimpleItem
class FolderHandler: class FolderHandler:
"""Folder object handler""" """Folder object handler"""
...@@ -55,7 +56,8 @@ class FolderHandler: ...@@ -55,7 +56,8 @@ class FolderHandler:
class Folder(ObjectManager,RoleManager,DocumentHandler, class Folder(ObjectManager,RoleManager,DocumentHandler,
ImageHandler,FolderHandler,UserFolderHandler): ImageHandler,FolderHandler,UserFolderHandler,
SimpleItem.Item):
"""Folder object""" """Folder object"""
meta_type='Folder' meta_type='Folder'
id ='folder' id ='folder'
......
"""Image object""" """Image object"""
__version__='$Revision: 1.4 $'[11:-2] __version__='$Revision: 1.5 $'[11:-2]
from Persistence import Persistent from Persistence import Persistent
from Globals import HTMLFile from Globals import HTMLFile
from Globals import MessageDialog
from AccessControl.Role import RoleManager from AccessControl.Role import RoleManager
import SimpleItem
class Image(Persistent,RoleManager): class Image(Persistent,RoleManager,SimpleItem.Item_w__name__):
"""Image object""" """Image object"""
meta_type='Image' meta_type='Image'
title =''
icon ='OFS/Image_icon.gif' icon ='OFS/Image_icon.gif'
manage_editForm =HTMLFile('OFS/imageEdit') manage_editForm =HTMLFile('OFS/imageEdit')
manage=manage_main=manage_editForm manage=manage_main=manage_editForm
manage_options=() def manage_edit(self,file,title,content_type='',acl_type='A',acl_roles=[], REQUEST=None):
def manage_edit(self,file,title,content_type='',acl_type='A',acl_roles=[]):
""" """ """ """
try: headers=file.headers try: headers=file.headers
except: headers=None except: headers=None
...@@ -28,11 +27,20 @@ class Image(Persistent,RoleManager): ...@@ -28,11 +27,20 @@ class Image(Persistent,RoleManager):
self.content_type=content_type self.content_type=content_type
self.data=file self.data=file
elif file: elif file:
data=file.read() try:
self.content_type=headers['content-type'] data=file.read()
self.data=data content_type=headers['content-type']
if data:
self.data=data
self.content_type=content_type
except: pass
self.title=title self.title=title
self._setRoles(acl_type,acl_roles) self._setRoles(acl_type,acl_roles)
return MessageDialog(
title ='Changed %s' % self.__name__,
message='%s has been updated' % self.__name__,
action =REQUEST['URL2']+'/manage_main',
target ='manage_main')
def _init(self,id,file,content_type=''): def _init(self,id,file,content_type=''):
try: headers=file.headers try: headers=file.headers
......
#!/bin/env python
##############################################################################
#
# Copyright
#
# Copyright 1997 Digital Creations, L.C., 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
# rights reserved.
#
##############################################################################
'''This module implements a simple item mix-in for objects that have a
very simple (e.g. one-screen) management interface, like documents,
Aqueduct database adapters, etc.
This module can also be used as a simple template for implementing new
item types.
$Id: SimpleItem.py,v 1.1 1997/09/10 18:42:36 jim Exp $'''
__version__='$Revision: 1.1 $'[11:-2]
class Item:
# Name, relative to SOFTWARE_URL of icon used to display item
# in folder listings.
icon='App/arrow.jpg'
# Meta type used for selecting all objects of a given type.
meta_type='simple item'
# Default title.
title=''
# Empty manage_options signals that this object has a
# single-screen management interface.
manage_options=()
# Utility that returns the title if it is not blank and the id
# otherwise.
def title_or_id(self):
return self.title or self.id
# Utility that returns the title if it is not blank and the id
# otherwise. If the title is not blank, then the id is included
# in parens.
def title_and_id(self):
t=self.title
return t and ("%s (%s)" % (t,self.id)) or self.id
# Handy way to talk to ourselves in document templates.
def this(self):
return self
class Item_w__name__(Item):
# Utility that returns the title if it is not blank and the id
# otherwise.
def title_or_id(self):
return self.title or self.__name__
# Utility that returns the title if it is not blank and the id
# otherwise. If the title is not blank, then the id is included
# in parens.
def title_and_id(self):
t=self.title
return t and ("%s (%s)" % (t,self.__name__)) or self.__name__
##############################################################################
#
# $Log: SimpleItem.py,v $
# Revision 1.1 1997/09/10 18:42:36 jim
# Added SimpleItem mix-in and new title/id methods.
#
#
<HTML> <HTML><HEAD><TITLE><!--#var title_or_id--></TITLE></HEAD>
<HEAD>
<TITLE>
<!--#if title-->
<!--#var title-->
<!--#else title-->
<!--#var id-->
<!--#/if title-->
</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555"> <BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<H2> <H2><!--#var title_or_id--></H2>
<!--#if title-->
<!--#var title-->
<!--#else title-->
<!--#var id-->
<!--#/if title-->
</H2>
<P> <P>
<!--#if parentObject--> <!--#if parentObject-->
...@@ -23,11 +8,7 @@ ...@@ -23,11 +8,7 @@
<A HREF="<!--#var URL2-->/manage" target="_top"> <A HREF="<!--#var URL2-->/manage" target="_top">
<IMG SRC="<!--#var SOFTWARE_URL-->/OFS/UpFolder_icon.gif" BORDER=0> <IMG SRC="<!--#var SOFTWARE_URL-->/OFS/UpFolder_icon.gif" BORDER=0>
</A> </A>
Return to <!--#if title--> Return to <!--#var title_or_id-->
<!--#var title-->
<!--#else title-->
<!--#var id-->
<!--#/if title-->
<BR> <BR>
<!--#/in parentObject--> <!--#/in parentObject-->
<!--#/if parentObject--> <!--#/if parentObject-->
...@@ -44,9 +25,7 @@ ...@@ -44,9 +25,7 @@
<!--#/if sequence-var-manage_options-->> <!--#/if sequence-var-manage_options-->>
<IMG SRC="<!--#var SOFTWARE_URL-->/<!--#var icon-->" BORDER="0"> <IMG SRC="<!--#var SOFTWARE_URL-->/<!--#var icon-->" BORDER="0">
</A> </A>
<A HREF="<!--#var URL1-->/<!--#var id-->"><!--#if title--> <A HREF="<!--#var URL1-->/<!--#var id-->"><!--#var title_and_id--></A><BR>
<!--#var title--> (<!--#var id-->)<!--#else title-->
<!--#var id--><!--#/if title--></A><BR>
<!--#/in objectValues--> <!--#/in objectValues-->
<!--#/if objectValues--> <!--#/if objectValues-->
...@@ -76,7 +55,7 @@ To delete items, select one or more items and click &quot;Delete&quot;. ...@@ -76,7 +55,7 @@ To delete items, select one or more items and click &quot;Delete&quot;.
<FORM ACTION="<!--#var PARENT_URL-->/manage_delObjects" METHOD="GET"> <FORM ACTION="<!--#var PARENT_URL-->/manage_delObjects" METHOD="GET">
<SELECT NAME="ids:list" MULTIPLE SIZE="4"> <SELECT NAME="ids:list" MULTIPLE SIZE="4">
<!--#in objectValues--> <!--#in objectValues-->
<OPTION VALUE="<!--#var id-->"><!--#var title--> <OPTION VALUE="<!--#var id-->"><!--#var title_and_id-->
<!--#/in objectValues--> <!--#/in objectValues-->
</SELECT><BR> </SELECT><BR>
<INPUT TYPE="SUBMIT" VALUE="Delete"> <INPUT TYPE="SUBMIT" VALUE="Delete">
......
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