示例#1
0
    def perform_search(self, request, query, only_app):
        number, number_type = validate_isxn(query)
        if not number_type:
            return []
        else:
            query = {number_type: number}

        query = LibrarySearchQuery(**query)

        results = []
        for item in self.conf.provider.library_search(query):
            results.append({
                'title':
                item.title,
                'redirect_if_sole_result':
                True,
                'application':
                'library',
                'excerpt':
                '',
                'additional':
                '<strong>Library item</strong>, Publisher: %s' %
                item.publisher,
                'url':
                reverse('library:item-detail', args=[item.control_number]),
            })

        print results

        return results
示例#2
0
    def handle_GET(self, request, context):
        search_form = context['search_form']

        if not (request.GET and search_form.is_valid()):
            # No form data received
            return self.render(request, context, 'library/item_list')

        # Build a query object to pass to providers here
        try:
            query = LibrarySearchQuery(search_form.cleaned_data['title'],
                                       search_form.cleaned_data['author'],
                                       search_form.cleaned_data['isbn'])
        except LibrarySearchQuery.InconsistentQuery, e:
            return self.handle_error(request, context, e.msg)
示例#3
0
 def testISBNSearch(self):
     for isbn in TEST_ISBNS:
         q = LibrarySearchQuery(isbn=isbn)
         results = z3950.Z3950(TEST_HOST, TEST_DATABASE).library_search(q)
         self.assert_(len(results) > 0, "No results for ISBN %s" % isbn)
示例#4
0
 def testOLISSearch(self):
     for author in TEST_AUTHORS:
         q = LibrarySearchQuery(author=author)
         results = z3950.Z3950(TEST_HOST, TEST_DATABASE).library_search(q)
         self.assert_(len(results) > 0)