Skip to content
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

Merged
merged 2 commits into from
May 18, 2024

Conversation

dataflake
Copy link
Member

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.

@dataflake dataflake self-assigned this May 17, 2024
d-maurer
d-maurer previously approved these changes May 17, 2024
@@ -0,0 +1 @@
application/vnd.zopefoundation.pagetemplate pt zpt
Copy link
Contributor

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).

elif typ in ('text/html', 'text/xml'):
elif typ in ('text/html',
'text/xml',
'application/vnd.zopefoundation.pagetemplate'):
Copy link
Contributor

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 (...

Copy link
Member

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?

@d-maurer
Copy link
Contributor

d-maurer commented May 17, 2024 via email

@dataflake
Copy link
Member Author

I chose the simplest possible solution.

@dataflake dataflake merged commit 0187e3a into master May 18, 2024
26 checks passed
@dataflake dataflake deleted the dataflake/define-custom-mimetypes branch May 18, 2024 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebDAV PUT factory behavior differs between platforms
3 participants