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
c2bb9c7d
Commit
c2bb9c7d
authored
May 10, 1999
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed mime-type sniffing to use OFS.content_types
parent
b6c854a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
30 deletions
+18
-30
lib/python/OFS/CopySupport.py
lib/python/OFS/CopySupport.py
+2
-2
lib/python/OFS/DTMLMethod.py
lib/python/OFS/DTMLMethod.py
+2
-2
lib/python/OFS/Image.py
lib/python/OFS/Image.py
+14
-26
No files found.
lib/python/OFS/CopySupport.py
View file @
c2bb9c7d
...
...
@@ -83,7 +83,7 @@
#
##############################################################################
__doc__
=
"""Copy interface"""
__version__
=
'$Revision: 1.3
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3
5
$'
[
11
:
-
2
]
import
sys
,
string
,
Globals
,
Moniker
,
tempfile
,
ExtensionClass
from
marshal
import
loads
,
dumps
...
...
@@ -332,7 +332,7 @@ class CopyContainer(ExtensionClass.Base):
meth
=
None
if
hasattr
(
self
,
method_name
):
meth
=
self
.
_getOb
(
method_name
)
meth
=
getattr
(
self
,
method_name
)
else
:
# Handle strange names that come from the Product
# machinery ;(
...
...
lib/python/OFS/DTMLMethod.py
View file @
c2bb9c7d
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""DTML Method objects."""
__version__
=
'$Revision: 1.2
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
2
$'
[
11
:
-
2
]
from
Globals
import
HTML
,
HTMLFile
,
MessageDialog
from
string
import
join
,
split
,
strip
,
rfind
,
atoi
,
lower
...
...
@@ -172,7 +172,7 @@ class DTMLMethod(cDocument, HTML, Acquisition.Implicit, RoleManager,
return
len
(
self
.
raw
)
getSize
=
get_size
def
old
validate
(
self
,
inst
,
parent
,
name
,
value
,
md
):
def
validate
(
self
,
inst
,
parent
,
name
,
value
,
md
):
#################################################################
# Note that this method is not used normally. It is simply a
# Python rendition of the validate method implemented in
...
...
lib/python/OFS/Image.py
View file @
c2bb9c7d
...
...
@@ -84,9 +84,10 @@
##############################################################################
"""Image object"""
__version__
=
'$Revision: 1.
69
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
70
$'
[
11
:
-
2
]
import
Globals
,
string
,
struct
,
mimetypes
,
content_types
import
Globals
,
string
,
struct
,
content_types
from
OFS.content_types
import
guess_content_type
from
Globals
import
HTMLFile
,
MessageDialog
from
PropertyManager
import
PropertyManager
from
AccessControl.Role
import
RoleManager
...
...
@@ -146,6 +147,7 @@ class File(Persistent,Implicit,PropertyManager,
self
.
__name__
=
id
self
.
title
=
title
self
.
precondition
=
precondition
filename
=
hasattr
(
file
,
'filename'
)
and
file
.
filename
or
None
headers
=
hasattr
(
file
,
'headers'
)
and
file
.
headers
or
None
if
hasattr
(
file
,
'read'
):
data
=
file
.
read
()
...
...
@@ -153,12 +155,8 @@ class File(Persistent,Implicit,PropertyManager,
if
headers
and
headers
.
has_key
(
'content-type'
)
and
(
not
content_type
):
content_type
=
headers
[
'content-type'
]
if
not
content_type
:
content_type
,
enc
=
mimetypes
.
guess_type
(
id
)
if
not
content_type
:
if
content_types
.
find_binary
(
data
)
>=
0
:
content_type
=
'application/octet-stream'
else
:
content_type
=
content_types
.
text_type
(
data
)
content_type
=
string
.
lower
(
content_type
)
filename
=
filename
or
id
content_type
,
enc
=
guess_content_type
(
id
,
data
)
self
.
update_data
(
data
,
content_type
)
def
id
(
self
):
...
...
@@ -199,7 +197,7 @@ class File(Persistent,Implicit,PropertyManager,
self
.
data
=
Pdata
(
data
)
self
.
size
=
len
(
data
)
def
manage_edit
(
self
,
title
,
content_type
,
precondition
=
''
,
REQUEST
=
None
):
def
manage_edit
(
self
,
title
,
content_type
,
precondition
=
''
,
REQUEST
=
None
):
"""
Changes the title and content type attributes of the File or Image.
"""
...
...
@@ -218,38 +216,28 @@ class File(Persistent,Implicit,PropertyManager,
The file or images contents are replaced with the contents of 'file'.
"""
filename
=
hasattr
(
file
,
'filename'
)
and
file
.
filename
or
None
headers
=
hasattr
(
file
,
'headers'
)
and
file
.
headers
or
None
data
=
(
headers
is
None
)
and
file
or
file
.
read
()
body
=
(
headers
is
None
)
and
file
or
file
.
read
()
if
headers
and
headers
.
has_key
(
'content-type'
):
content_type
=
headers
[
'content-type'
]
else
:
content_type
=
''
if
not
content_type
:
content_type
,
enc
=
mimetypes
.
guess_type
(
self
.
id
())
if
not
content_type
:
if
content_types
.
find_binary
(
data
)
>=
0
:
content_type
=
'application/octet-stream'
else
:
content_type
=
content_types
.
text_type
(
data
)
content_type
=
string
.
lower
(
content_type
)
self
.
update_data
(
data
,
content_type
)
filename
=
filename
or
self
.
id
()
content_type
,
enc
=
guess_content_type
(
self
.
id
(),
body
)
self
.
update_data
(
body
,
content_type
)
if
REQUEST
:
return
MessageDialog
(
title
=
'Success!'
,
message
=
'Your changes have been saved'
,
action
=
'manage_main'
)
def
PUT
(
self
,
REQUEST
,
RESPONSE
):
"""Handle HTTP PUT requests"""
self
.
dav__init
(
REQUEST
,
RESPONSE
)
type
=
REQUEST
.
get_header
(
'content-type'
,
None
)
body
=
REQUEST
.
get
(
'BODY'
,
''
)
if
type
is
None
:
type
,
enc
=
mimetypes
.
guess_type
(
self
.
id
())
if
type
is
None
:
if
content_types
.
find_binary
(
body
)
>=
0
:
type
=
'application/octet-stream'
else
:
type
=
content_types
.
text_type
(
body
)
type
=
string
.
lower
(
type
)
type
,
enc
=
guess_content_type
(
self
.
id
(),
body
)
self
.
update_data
(
body
,
type
)
RESPONSE
.
setStatus
(
204
)
return
RESPONSE
...
...
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