Redirecting and resource directories
====================================

When you try to visit a page that does not exist, Plone helpfully
shows a link to the parent directory.  Normally this is fine.  But
Plone expects this parent directory to be a normal folder or something
similar.  It makes some assumptions there that are not valid when the
parent is a resource directory.  This gives problems while rendering
the default error page.  In particular it results in a TypeError:
getTypeInfo.

We test this by starting up a test browser:

    >>> from plone.testing.z2 import Browser
    >>> app = layer['app']
    >>> browser = Browser(app)

Let's check what happens when we get a file from a resourceDirectory.
This flag exists:

  >>> flag_directory = 'http://nohost/plone/++resource++language-flags/'
  >>> browser.open(flag_directory + 'eu.gif')

And this flag does not, so it should raise a 404:

  >>> browser.open(flag_directory + 'nonexisting.gif')
  Traceback (most recent call last):
  ...
  HTTPError: HTTP Error 404: Not Found

But it should not give an error while rendering the default error page:

  >>> "the following error occurred while attempting to render the standard error message" in browser.contents
  False

As it is an image, it should return a JSON message
  >>> '{"error_type": "NotFound"}' in browser.contents
  True

A non-existing page would return a human readable error page
  >>> browser.addHeader('Accept', 'text/html')
  >>> browser.open('http://nohost/plone/non-existing-page')
  Traceback (most recent call last):
  ...
  HTTPError: HTTP Error 404: Not Found
  >>> "This page does not seem to exist" in browser.contents
  True
