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
1e60e0d1
Commit
1e60e0d1
authored
Feb 10, 1998
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Pdata to keep big blobs out of memory until needed
parent
e9447a6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
10 deletions
+28
-10
lib/python/OFS/Image.py
lib/python/OFS/Image.py
+28
-10
No files found.
lib/python/OFS/Image.py
View file @
1e60e0d1
"""Image object"""
__version__
=
'$Revision: 1.2
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
8
$'
[
11
:
-
2
]
import
Globals
from
Globals
import
HTMLFile
,
MessageDialog
...
...
@@ -10,6 +10,22 @@ from Persistence import Persistent
from
Acquisition
import
Implicit
class
Pdata
(
Persistent
,
Implicit
):
# Wrapper for possibly large data
def
__init__
(
self
,
data
):
self
.
data
=
data
def
__str__
(
self
):
return
self
.
data
def
__len__
(
self
):
return
len
(
self
.
data
)
class
File
(
Persistent
,
Implicit
,
RoleManager
,
Item_w__name__
):
""" """
meta_type
=
'File'
...
...
@@ -49,12 +65,13 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
if
not
content_type
:
raise
'BadValue'
,
'No content type specified'
self
.
content_type
=
content_type
self
.
data
=
file
self
.
data
=
Pdata
(
file
)
else
:
self
.
content_type
=
headers
[
'content-type'
]
self
.
data
=
file
.
read
(
)
self
.
data
=
Pdata
(
file
.
read
()
)
self
.
__name__
=
id
self
.
title
=
title
self
.
size
=
len
(
self
.
data
)
def
id
(
self
):
return
self
.
__name__
...
...
@@ -74,11 +91,10 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
def
manage_upload
(
self
,
file
=
''
,
REQUEST
=
None
):
""" """
headers
=
file
.
headers
self
.
content_type
=
file
.
headers
[
'content-type'
]
data
=
file
.
read
()
content_type
=
headers
[
'content-type'
]
self
.
data
=
data
self
.
content_type
=
content_type
self
.
data
=
Pdata
(
data
)
self
.
size
=
len
(
data
)
if
REQUEST
:
return
MessageDialog
(
title
=
'Success!'
,
message
=
'Your changes have been saved'
,
...
...
@@ -87,16 +103,18 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
PUT__roles__
=
[
'Manager'
]
def
PUT
(
self
,
BODY
,
REQUEST
):
'handle PUT requests'
self
.
data
=
BODY
self
.
data
=
Pdata
(
BODY
)
self
.
size
=
len
(
BODY
)
try
:
type
=
REQUEST
[
'CONTENT_TYPE'
]
if
type
:
self
.
content_type
=
type
except
KeyError
:
pass
def
__str__
(
self
):
return
self
.
data
def
size
(
self
):
return
len
(
self
.
data
)
def
__str__
(
self
):
return
str
(
self
.
data
)
def
__len__
(
self
):
return
1
def
size
(
self
):
return
len
(
self
.
data
)
class
Image
(
File
):
...
...
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