-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define custom content type for Page Template (fixes #1212) #1213
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
application/vnd.zopefoundation.pagetemplate pt zpt | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, we could apply the same logic as for elif ext in ('.pt', '.zpt') or typ in (... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Relying on the extension might indeed be better. Otherwise I wonder what happens when the operating system associates |
||
ob = ZopePageTemplate(name, body, content_type=typ) | ||
elif typ.startswith('image/'): | ||
ob = Image(name, '', body, content_type=typ) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In view of https://www.rfc-editor.org/rfc/rfc2046#section-6 we likely should start our subtype with
X-
(indicating a somewhat unofficial value).Because a page template is mostly human readable,
text
might be better thanapplication
as top level type.However, because we only plan to use the type internally (and not for publication), the precise value is not of great importance.
We might also check that the appearance of a ".pt -> MIME type" map in public registries does not pose a problem on a different route: browsers may consult those registries to automatically provide a "Content-Type" header which might prevent our guessing. However, if this really happens, I have no idea how to prevent it (the browser's info may be authoritative and not based on guessing).