Skip to content

Commit

Permalink
- define custom content type for Page Template (fixes #1212)
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed May 17, 2024
1 parent 98b703e commit 08cf823
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ additional-rules = [
"recursive-include src *.svg",
"recursive-include src *.ttf",
"recursive-include src *.txt",
"recursive-include src *.types",
"recursive-include src *.webmanifest",
"recursive-include src *.woff",
"recursive-include src *.woff2",
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ https://github.com/zopefoundation/Zope/blob/4.x/CHANGES.rst
5.9.1 (unreleased)
------------------

- Define a custom MIME type for Zope Page Templates
instead of relying on platform-dependent MIME type configurations.
(`#1212 <https://github.com/zopefoundation/Zope/issues/1212>`_)

- Clean up and fix installation documentation.

- Officially support Python 3.12.1.
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ recursive-include src *.rst
recursive-include src *.svg
recursive-include src *.ttf
recursive-include src *.txt
recursive-include src *.types
recursive-include src *.webmanifest
recursive-include src *.woff
recursive-include src *.woff2
Expand Down
9 changes: 9 additions & 0 deletions src/Products/PageTemplates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
This wrapper allows the Page Template modules to be segregated in a
separate package.
"""
import os

from zope.contenttype import add_files


# Placeholder for Zope Product data
misc_ = {}
Expand All @@ -29,3 +33,8 @@ def initialize(context):
# Import lazily, and defer initialization to the module
from . import ZopePageTemplate
ZopePageTemplate.initialize(context)

# Add the custom MIME type information for Page Templates
# to the Python mimetypes module so they are recognized correctly
here = os.path.dirname(os.path.abspath(__file__))
add_files([os.path.join(here, 'mime.types')])
1 change: 1 addition & 0 deletions src/Products/PageTemplates/mime.types
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/vnd.zopefoundation.pagetemplate pt zpt
4 changes: 3 additions & 1 deletion src/webdav/NullResource.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ def _default_PUT_factory(self, name, typ, body):

if ext == '.dtml':
ob = DTMLDocument('', __name__=name)
elif typ in ('text/html', 'text/xml'):
elif typ in ('text/html',
'text/xml',
'application/vnd.zopefoundation.pagetemplate'):
ob = ZopePageTemplate(name, body, content_type=typ)
elif typ.startswith('image/'):
ob = Image(name, '', body, content_type=typ)
Expand Down

0 comments on commit 08cf823

Please sign in to comment.