========
Contents
========

The goal of this package is to offer a modular replacement for the default 
contents.html page used in Zope3.


Initially
=========

In ftesting.zcml we have set up a test layer to use for the following tests and
have also registered a Contents view as 'index' for the root folder:

  >>> from z3c.etestbrowser.testing import ExtendedTestBrowser
  >>> import zope.component
  >>> browser = ExtendedTestBrowser()
  >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
  >>> browser.handleErrors = False
  >>> URL = 'http://localhost/++skin++ContentsTesting%s'

We have sorting urls in the column headers. Initially the table is sorted on the
name column ascending.

  >>> browser.open(URL % '/')
  >>> printElement(browser, "//table/thead/tr/th", multiple=True)
  <th>X</th>
  <th><a
    href="?contents-sortOn=contents-renameColumn-1&amp;contents-sortOrder=descending"
    title="Sort">Name</a></th>
  <th><a
    href="?contents-sortOn=contents-createdColumn-2&amp;contents-sortOrder=ascending"
    title="Sort">Created</a></th>
  <th><a
    href="?contents-sortOn=contents-modifiedColumn-3&amp;contents-sortOrder=ascending"
    title="Sort">Modified</a></th>


Sample data set up
==================

  >>> container = getRootFolder()
  >>> from z3c.contents.testing import Content
  >>> container[u'zero'] = Content('Zero', 0)
  >>> container[u'first'] = Content('First', 1)
  >>> container[u'second'] = Content('Second', 2)
  >>> container[u'third'] = Content('Third', 3)
  >>> container[u'fourth'] = Content('Fourth', 4)

We can search within the container - this is a simple search on ids and string
attributes on the contained objects.

  >>> browser.getControl(name="search.widgets.searchterm").value = u'4 second Third'
  >>> browser.getControl(name="search.buttons.search").click()

Note that the searchterms are also now included in the sorting header link.

  >>> printElement(browser, "//table/thead/tr/th[2]")
  <th><a
    href="?contents-sortOn=contents-renameColumn-1&amp;contents-sortOrder=descending&amp;search.widgets.searchterm=4+second+Third"
    title="Sort">Name</a></th>
