Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
294dcda0
Commit
294dcda0
authored
Mar 18, 1998
by
Jeffrey Shell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some encyclopedic information
parent
98f69ed2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
24 deletions
+82
-24
lib/python/OFS/Document.py
lib/python/OFS/Document.py
+22
-5
lib/python/OFS/Folder.py
lib/python/OFS/Folder.py
+18
-8
lib/python/OFS/Image.py
lib/python/OFS/Image.py
+42
-11
No files found.
lib/python/OFS/Document.py
View file @
294dcda0
"""Document object"""
__version__
=
'$Revision: 1.4
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
5
$'
[
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
...
...
lib/python/OFS/Folder.py
View file @
294dcda0
"""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'
,
[
''
]),
)
...
...
lib/python/OFS/Image.py
View file @
294dcda0
"""Image object"""
__version__
=
'$Revision: 1.3
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3
5
$'
[
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'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment