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
5de6d548
Commit
5de6d548
authored
Mar 23, 1998
by
Paul Everitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a precondition to File objects
parent
e1717745
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
9 deletions
+74
-9
lib/python/OFS/Image.py
lib/python/OFS/Image.py
+25
-9
lib/python/OFS/fileEdit.dtml
lib/python/OFS/fileEdit.dtml
+49
-0
No files found.
lib/python/OFS/Image.py
View file @
5de6d548
"""Image object"""
__version__
=
'$Revision: 1.3
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3
6
$'
[
11
:
-
2
]
import
Globals
from
Globals
import
HTMLFile
,
MessageDialog
...
...
@@ -11,11 +11,12 @@ from Acquisition import Implicit
from
DateTime
import
DateTime
manage_addFileForm
=
HTMLFile
(
'imageAdd'
,
globals
(),
Kind
=
'File'
,
kind
=
'file'
)
def
manage_addFile
(
self
,
id
,
file
,
title
=
''
,
REQUEST
=
None
):
def
manage_addFile
(
self
,
id
,
file
,
title
=
''
,
precondition
=
''
,
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
))
self
.
_setObject
(
id
,
File
(
id
,
title
,
file
,
precondition
))
return
self
.
manage_main
(
self
,
REQUEST
)
...
...
@@ -27,8 +28,9 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
meta_type
=
'File'
icon
=
'p_/file'
precondition
=
''
manage_editForm
=
HTMLFile
(
'
imag
eEdit'
,
globals
(),
Kind
=
'File'
,
kind
=
'file'
)
manage_editForm
=
HTMLFile
(
'
fil
eEdit'
,
globals
(),
Kind
=
'File'
,
kind
=
'file'
)
manage_uploadForm
=
HTMLFile
(
'imageUpload'
,
globals
(),
Kind
=
'File'
,
kind
=
'file'
)
manage
=
manage_main
=
manage_editForm
...
...
@@ -47,7 +49,8 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
)
def
__init__
(
self
,
id
,
title
,
file
,
content_type
=
'application/octet-stream'
):
def
__init__
(
self
,
id
,
title
,
file
,
precondition
=
''
,
content_type
=
'application/octet-stream'
):
try
:
headers
=
file
.
headers
except
:
headers
=
None
if
headers
is
None
:
...
...
@@ -65,33 +68,46 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
self
.
data
=
Pdata
(
file
.
read
())
self
.
__name__
=
id
self
.
title
=
title
if
precondition
:
self
.
precondition
=
precondition
self
.
size
=
len
(
self
.
data
)
def
id
(
self
):
return
self
.
__name__
def
index_html
(
self
,
RESPONSE
):
def
index_html
(
self
,
RE
QUEST
,
RE
SPONSE
):
"""
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.
"""
if
self
.
precondition
and
hasattr
(
self
,
self
.
precondition
):
# Grab whatever precondition was defined and then
# execute it. The precondition will raise an exception
# if something violates its terms.
c
=
getattr
(
self
,
self
.
precondition
)
if
hasattr
(
c
,
'isDocTemp'
)
and
c
.
isDocTemp
:
c
(
REQUEST
[
'PARENTS'
][
1
],
REQUEST
)
else
:
c
()
RESPONSE
[
'content-type'
]
=
self
.
content_type
return
self
.
data
def
view_image_or_file
(
self
,
RESPONSE
):
def
view_image_or_file
(
self
,
REQUEST
,
RESPONSE
):
"""
The default view of the contents of the File or Image.
"""
return
self
.
index_html
(
RESPONSE
)
return
self
.
index_html
(
RE
QUEST
,
RE
SPONSE
)
def
manage_edit
(
self
,
title
,
content_type
,
REQUEST
=
None
):
def
manage_edit
(
self
,
title
,
content_type
,
precondition
=
''
,
REQUEST
=
None
):
"""
Changes the title and content type attributes of the File or Image.
"""
self
.
title
=
title
self
.
content_type
=
content_type
if
precondition
:
self
.
precondition
=
precondition
elif
self
.
precondition
:
del
self
.
precondition
if
REQUEST
:
return
MessageDialog
(
title
=
'Success!'
,
message
=
'Your changes have been saved'
,
...
...
lib/python/OFS/fileEdit.dtml
0 → 100644
View file @
5de6d548
<HTML>
<HEAD>
<TITLE>Edit</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<!--#var manage_tabs-->
<FORM ACTION="manage_edit" METHOD="POST" TARGET="manage_main">
<TABLE CELLSPACING="2">
<TR>
<TH ALIGN="LEFT" VALIGN="TOP">Id</STRONG></TH>
<TD ALIGN="LEFT" VALIGN="TOP"><!--#var id--></TD>
</TR>
<TR>
<TH ALIGN="LEFT" VALIGN="TOP"><EM>Title</EM></TH>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="title" SIZE="40" VALUE="<!--#var title-->">
</TD>
</TR>
<TR>
<TH ALIGN="LEFT" VALIGN="TOP">Content Type</TH>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="content_type:required" SIZE="40"
VALUE="<!--#var content_type-->">
</TD>
</TR>
<TR>
<TH ALIGN="LEFT" VALIGN="TOP"><em>Precondition</em></TH>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="precondition" SIZE="40"
VALUE="<!--#var precondition-->">
</TD>
</TR>
<TR>
<TH ALIGN="LEFT" VALIGN="TOP">Size</TH>
<TD ALIGN="LEFT" VALIGN="TOP"><!--#var size thousands_commas--> bytes</TD>
</TR>
<TR>
<TH ALIGN="LEFT" VALIGN="TOP">Last modified</TH>
<TD ALIGN="LEFT" VALIGN="TOP"><!--#var bobobase_modification_time--></TD>
</TR>
<TR>
<TD></TD><TD><BR><INPUT TYPE="SUBMIT" VALUE="Change"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
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