"""Module containing the service handlers for pre-defined searches on
the repository.
"""

from mod_python import apache

import search_utils
import search_xml

###

def find_unowned ( request, form ):
    """Return all currently unowned resources.

    The XML result is described in the property_search.txt document in
    the railroad doc directory.
    """
    # set parameters
    start_date = form.get('start-date', None)
    end_date = form.get('end-date', None)
    mime_type = form.get('mime-type', None)
    result = search_xml.SearchResult(request.uri)
    try:
        search_utils.search_unowned(result, start_date, end_date, mime_type)
    except search_utils.NothingFound:
        pass
    txt = result.as_string()
    request.content_type = 'text/xml'
    request.set_content_length(len(txt))
    request.write(txt)
    return apache.OK
#
###

