-
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
Conversation
@@ -0,0 +1 @@ | |||
application/vnd.zopefoundation.pagetemplate pt zpt |
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 than application
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).
src/webdav/NullResource.py
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we could apply the same logic as for .dtml
, e.g. use
elif ext in ('.pt', '.zpt') or typ in (...
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.
Relying on the extension might indeed be better.
Otherwise I wonder what happens when the operating system associates .pt
with that other mime type you found. Does the new Zope definition win? Does the OS definition win? Does it matter on the order in which the two definitions get loaded?
Maurits van Rees wrote at 2024-5-17 12:32 -0700:
...
Relying on the extension might indeed be better.
Otherwise I wonder what happens when the operating system associates `.pt` with that other mime type you found. Does the new Zope definition win?
All depends on Python's `mimetypes` module.
This promises that later registered type files take precedence over
former ones. The first type files registered are those provided
by the system.
Thus, the Zope definition will win unless the application
registers additional files with conflicting definitions.
Does the OS definition win? Does it matter on the order in which the two definitions get loaded?
In principle, yes: but the system provided files are registered
before any others.
|
I chose the simplest possible solution. |
Fixes #1212
I chose to put the
mime.types
file into the PageTemplates product itself because I didn't see a sensible place elsewhere where I can load it during initialization.