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
5a2b0915
Commit
5a2b0915
authored
Dec 10, 2005
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replaced with aliases for Z3 methods
parent
8524241c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
58 deletions
+1
-58
lib/python/OFS/content_types.py
lib/python/OFS/content_types.py
+1
-58
No files found.
lib/python/OFS/content_types.py
View file @
5a2b0915
...
@@ -14,62 +14,5 @@
...
@@ -14,62 +14,5 @@
$Id$
$Id$
"""
"""
import
mimetypes
import
os.path
import
re
from
zope.app.content_types
import
text_type
,
guess_content_type
find_binary
=
re
.
compile
(
'[
\
0
-
\
7
]'
).
search
def
text_type
(
s
):
# Yuk. See if we can figure out the type by content.
if
(
s
.
strip
().
lower
()[:
6
]
==
'<html>'
or
s
.
find
(
'</'
)
>
0
):
return
'text/html'
elif
s
.
strip
().
startswith
(
'<?xml'
):
return
'text/xml'
else
:
return
'text/plain'
def
guess_content_type
(
name
=
''
,
body
=
''
,
default
=
None
):
# Attempt to determine the content type (and possibly
# content-encoding) based on an an object's name and
# entity body.
type
,
enc
=
mimetypes
.
guess_type
(
name
)
if
type
is
None
:
if
body
:
if
find_binary
(
body
)
is
not
None
:
type
=
default
or
'application/octet-stream'
else
:
type
=
(
default
or
text_type
(
body
)
or
'text/x-unknown-content-type'
)
else
:
type
=
default
or
'text/x-unknown-content-type'
return
type
.
lower
(),
enc
and
enc
.
lower
()
or
None
def
add_files
(
filenames
):
# Make sure the additional files are either loaded or scheduled to
# be loaded:
if
mimetypes
.
inited
:
# Re-initialize the mimetypes module, loading additional files
mimetypes
.
init
(
filenames
)
else
:
# Tell the mimetypes module about the additional files so
# when it is initialized, it will pick up all of them, in
# the right order.
mimetypes
.
knownfiles
.
extend
(
filenames
)
# Provide definitions shipped as part of Zope:
here
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
add_files
([
os
.
path
.
join
(
here
,
"mime.types"
)])
if
__name__
==
'__main__'
:
items
=
mimetypes
.
types_map
.
items
()
items
.
sort
()
for
item
in
items
:
print
"%s:
\
t
%s"
%
item
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