Commit 294dcda0 authored by Jeffrey Shell's avatar Jeffrey Shell

Added some encyclopedic information

parent 98f69ed2
"""Document object"""
__version__='$Revision: 1.44 $'[11:-2]
__version__='$Revision: 1.45 $'[11:-2]
from Globals import HTML, HTMLFile, MessageDialog
from string import join,split,strip,rfind,atoi
......@@ -108,7 +108,15 @@ class Document(HTML, Explicit, RoleManager, Item_w__name__):
def manage_edit(self,data,title,SUBMIT='Change',dtpref_cols='50',
dtpref_rows='20',REQUEST=None):
""" """
"""
Replaces a Documents contents with Data, Title with Title.
The SUBMIT parameter is also used to change the size of the editing
area on the default Document edit screen. If the value is "Smaller",
the rows and columns decrease by 5. If the value is "Bigger", the
rows and columns increase by 5. If any other or no value is supplied,
the data gets checked for DTML errors and is saved.
"""
self._validateProxy(REQUEST)
if SUBMIT=='Smaller':
rows=atoi(dtpref_rows)-5
......@@ -136,7 +144,9 @@ class Document(HTML, Explicit, RoleManager, Item_w__name__):
action ='manage_main')
def manage_upload(self,file='', REQUEST=None):
""" """
"""
replace the contents of the document with the text in file.
"""
self._validateProxy(REQUEST)
self.munge(file.read())
if REQUEST: return MessageDialog(
......@@ -146,7 +156,9 @@ class Document(HTML, Explicit, RoleManager, Item_w__name__):
PUT__roles__='Manager',
def PUT(self, BODY, REQUEST):
""" """
"""
replaces the contents of the document with the BODY of an HTTP PUT request.
"""
self._validateProxy(REQUEST)
self.munge(BODY)
return 'OK'
......@@ -190,7 +202,12 @@ the <!--#var title_and_id--> Folder.</P>
manage_addDocumentForm=HTMLFile('documentAdd', globals())
def manage_addDocument(self,id,title='',file='',REQUEST=None):
""" """
"""
Add a Document object with the contents of file.
If 'file' is empty or unspecified, the created documents contents are set
to Principia's preset default.
"""
if not file: file=default_html
i=Document(file, __name__=id)
i.title=title
......
"""Folder object
$Id: Folder.py,v 1.39 1998/03/09 19:39:05 jim Exp $"""
$Id: Folder.py,v 1.40 1998/03/18 21:07:46 jeffrey Exp $"""
__version__='$Revision: 1.39 $'[11:-2]
__version__='$Revision: 1.40 $'[11:-2]
from Globals import HTMLFile
......@@ -21,7 +21,12 @@ manage_addFolderForm=HTMLFile('folderAdd', globals())
def manage_addFolder(self,id,title='',createPublic=0,createUserF=0,
REQUEST=None):
"""Add a new Folder object"""
"""Add a new Folder object with id *id*.
If the 'createPublic' and 'createUserF' parameters are set to any true
value, an 'index_html' and a 'UserFolder' objects are created respectively
in the new folder.
"""
i=self.folderClass()()
i.id=id
i.title=title
......@@ -32,7 +37,10 @@ def manage_addFolder(self,id,title='',createPublic=0,createUserF=0,
class Folder(ObjectManager,RoleManager,DocumentHandler,
SimpleItem.Item,CopyContainer):
""" """
"""
The basic container object in Principia. Folders can hold almost all
other Principia objects.
"""
__roles__=['Manager', 'Shared']
meta_type='Folder'
......@@ -63,14 +71,16 @@ class Folder(ObjectManager,RoleManager,DocumentHandler,
__ac_permissions__=(
('View management screens',
['manage','manage_menu','manage_main','manage_copyright',
'manage_tabs','manage_propertiesForm','manage_UndoForm']),
'manage_tabs','manage_propertiesForm','manage_UndoForm',
'objectIds', 'objectValues', 'objectItems','hasProperty']),
('Undo changes', ['manage_undo_transactions']),
('Change permissions', ['manage_access']),
('Add objects', ['manage_addObject']),
('Delete objects', ['manage_delObjects']),
('Add properties', ['manage_addProperty']),
('Change properties', ['manage_editProperties']),
('Delete properties', ['manage_delProperties']),
('Manage properties', ['manage_addProperty', 'manage_editProperties',
'manage_delProperties', 'propertyIds',
'propertyValues','propertyItems',
'manage_changeProperties']),
('Shared permission', ['']),
)
......
"""Image object"""
__version__='$Revision: 1.34 $'[11:-2]
__version__='$Revision: 1.35 $'[11:-2]
import Globals
from Globals import HTMLFile, MessageDialog
......@@ -12,13 +12,19 @@ from DateTime import DateTime
manage_addFileForm=HTMLFile('imageAdd', globals(),Kind='File',kind='file')
def manage_addFile(self,id,file,title='',REQUEST=None):
""" """
"""Add a new File object.
Creates a new file object 'id' with the contents of 'file'"""
self._setObject(id, File(id,title,file))
return self.manage_main(self,REQUEST)
class File(Persistent,Implicit,RoleManager,Item_w__name__):
""" """
"""
Principia object for arbitrary files. A Files string representation is
its contents.
"""
meta_type='File'
icon='p_/file'
......@@ -36,7 +42,7 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
('View management screens', ['manage','manage_tabs','manage_uploadForm']),
('Change permissions', ['manage_access']),
('Change/upload data', ['manage_edit','manage_upload','PUT']),
('View', ['index_html', 'view_image_or_file', 'getSize', 'getContentType']),
('View', ['index_html','view_image_or_file','getSize','getContentType']),
('Shared permission', ['',]),
)
......@@ -65,16 +71,25 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
def index_html(self, RESPONSE):
""" """
"""
The default view of the contents of the File or Image.
Returns the contents of the file or image. Also, sets the
'content-type' HTTP header to the objects content type.
"""
RESPONSE['content-type'] =self.content_type
return self.data
def view_image_or_file(self, RESPONSE):
""" """
"""
The default view of the contents of the File or Image.
"""
return self.index_html(RESPONSE)
def manage_edit(self,title,content_type,REQUEST=None):
""" """
"""
Changes the title and content type attributes of the File or Image.
"""
self.title=title
self.content_type=content_type
if REQUEST: return MessageDialog(
......@@ -83,7 +98,11 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
action ='manage_main')
def manage_upload(self,file='',REQUEST=None):
""" """
"""
Replaces the current contents of the File or Image object with file.
The file or images contents are replaced with the contents of 'file'.
"""
self.content_type=file.headers['content-type']
data=file.read()
self.data=Pdata(data)
......@@ -111,12 +130,16 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
def getSize(self):
"""Get the size of a file or image
"""Get the size of a file or image.
Returns the size of the file or image.
"""
return len(self.data)
def getContentType(self):
"""Get the content type of a file or image
"""Get the content type of a file or image.
Returns the content type (MIME type) of a file or image.
"""
return self.content_type
......@@ -127,11 +150,19 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
manage_addImageForm=HTMLFile('imageAdd',globals(),Kind='Image',kind='image')
def manage_addImage(self,id,file,title='',REQUEST=None):
""" """
"""
Add a new Image object.
Creates a new Image object 'id' with the contents of 'file'.
"""
self._setObject(id, Image(id,title,file))
return self.manage_main(self,REQUEST)
class Image(File):
"""Principia object for *Images*, can be GIF or JPEG. Has the same
methods as File objects. Images also have a string representation
that renders an HTML 'IMG' tag.
"""
meta_type='Image'
icon ='p_/image'
......
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