Serving static html secured by permissions in Plone

248 Views Asked by At

I'd like to use something like the ZCML snippet below in my ZCML file to serve static HTML files from a directory. The files must be secured by a permission such as "cmf.ManagePortal", "zope.ManageContent" or similar.

<browser:resourceDirectory
directory="resource"
name="myresource"
permission="zope.ManageContent" />

Currently the plain html files are parsed as if they were zope page templates which is not what I want. According to http://bluebream.zope.org/doc/1.0/manual/browserresource.html#directory-resource .html, .pt and .zpt extensions are parsed as page templates.

I just want to serve the html as is.

I know about <plone:static ...> which is available with plone.resource but it doesn't support setting permissions which is something I'd like to have for my usecase.

I'm looking for guidance with one of the following:

a) A way to "deregister .html extensions from being parsed as page templates when in a resource directory.

b) A way to apply permissions to a static directory declared using <plone:static ...>

The following works when added to my ZCML but doesn't support setting a permission:

<include package="plone.resource" />
    <plone:static
      type="theme"
      name="build"
      directory="_build/html"
  />
1

There are 1 best solutions below

0
On

I can only imagine a monkey-patch to pop an entry from std lib's mimetypes.types_map dictionary. Maybe you'll want to pop key '.htm' and then reconfigure your Sphinx extension output so you can keep '.html' intact.

You can code that directly on your package's init.py or register it in the ZCA with collective.monkeypatcher.