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
a2aba894
Commit
a2aba894
authored
Mar 03, 1998
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added last-modifed and HEAD support
parent
6b633d56
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
3 deletions
+33
-3
lib/python/OFS/Image.py
lib/python/OFS/Image.py
+33
-3
No files found.
lib/python/OFS/Image.py
View file @
a2aba894
"""Image object"""
__version__
=
'$Revision: 1.
29
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
30
$'
[
11
:
-
2
]
import
Globals
from
Globals
import
HTMLFile
,
MessageDialog
...
...
@@ -8,7 +8,7 @@ from AccessControl.Role import RoleManager
from
SimpleItem
import
Item_w__name__
from
Persistence
import
Persistent
from
Acquisition
import
Implicit
from
DateTime
import
DateTime
class
Pdata
(
Persistent
,
Implicit
):
...
...
@@ -77,18 +77,39 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
self
.
__name__
=
id
self
.
title
=
title
self
.
size
=
len
(
self
.
data
)
self
.
setLastModifiedHeader
()
def
id
(
self
):
return
self
.
__name__
def
getLastModifiedHeader
(
self
):
"""Return a timestamp string representing the last
modification time, in a format that can used in
an HTTP header."""
if
hasattr
(
self
,
'hmod'
):
return
self
.
hmod
self
.
hmodified
=
DateTime
().
toZone
(
'GMT'
).
rfc822
()
return
self
.
hmodified
def
setLastModifiedHeader
(
self
,
ts
=
None
):
"""Set the timestamp string representing the last
modification time to the given string. The time
stamp string must be expressed in GMT, in rfc822
format. If no string is specified, a timestamp
representing the current time will be used."""
if
ts
:
self
.
hmodified
=
ts
else
:
self
.
hmodified
=
DateTime
().
toZone
(
'GMT'
).
rfc822
()
def
index_html
(
self
,
RESPONSE
):
""" """
RESPONSE
[
'content-type'
]
=
self
.
content_type
RESPONSE
[
'content-type'
]
=
self
.
content_type
RESPONSE
[
'last-modified'
]
=
self
.
getLastModifiedHeader
()
return
self
.
data
def
manage_edit
(
self
,
title
,
content_type
,
REQUEST
=
None
):
""" """
self
.
title
=
title
self
.
content_type
=
content_type
self
.
setLastModifiedHeader
()
if
REQUEST
:
return
MessageDialog
(
title
=
'Success!'
,
message
=
'Your changes have been saved'
,
...
...
@@ -100,16 +121,25 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
data
=
file
.
read
()
self
.
data
=
Pdata
(
data
)
self
.
size
=
len
(
data
)
self
.
setLastModifiedHeader
()
if
REQUEST
:
return
MessageDialog
(
title
=
'Success!'
,
message
=
'Your changes have been saved'
,
action
=
'manage_main'
)
HEAD__roles__
=
None
def
HEAD
(
self
,
REQUEST
,
RESPONSE
):
""" """
RESPONSE
[
'content-type'
]
=
self
.
content_type
RESPONSE
[
'last-modified'
]
=
self
.
getLastModifiedHeader
()
return
''
PUT__roles__
=
[
'Manager'
]
def
PUT
(
self
,
BODY
,
REQUEST
):
'handle PUT requests'
self
.
data
=
Pdata
(
BODY
)
self
.
size
=
len
(
BODY
)
self
.
setLastModifiedHeader
()
try
:
type
=
REQUEST
[
'CONTENT_TYPE'
]
if
type
:
self
.
content_type
=
type
...
...
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