3

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"
  />
David Bain
  • 2,439
  • 1
  • 17
  • 19
  • Probably the only way is to serve them as page templates. What is your problem about this (apart CPU time wasting)? – keul Mar 28 '14 at 11:39
  • 1
    @keul, it can work however the html that Sphinx is spitting out is apparently not well formed enough for the parser. As a result I keep getting errors. I was really hoping to avoid having to do too much tinkering. It seems I either need to fix Sphinx or tinker with Zope. – David Bain Mar 31 '14 at 19:29

1 Answers1

0

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.

Davi Lima
  • 800
  • 1
  • 6
  • 20