本文整理汇总了Python中eulfedora.server.Repository.default_object_type方法的典型用法代码示例。如果您正苦于以下问题:Python Repository.default_object_type方法的具体用法?Python Repository.default_object_type怎么用?Python Repository.default_object_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eulfedora.server.Repository
的用法示例。
在下文中一共展示了Repository.default_object_type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: browse
# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import default_object_type [as 别名]
def browse(request):
"Browse postcards and display thumbnail images."
repo = Repository()
repo.default_object_type = ImageObject
number_of_results = 15
context = {}
search_opts = postcard_search_opts().copy()
if 'subject' in request.GET:
context['subject'] = request.GET['subject']
search_opts['subject'] = request.GET['subject']
postcards = repo.find_objects(**search_opts)
postcard_paginator = Paginator(list(postcards), number_of_results)
try:
page = int(request.GET.get('page', '1'))
except ValueError:
page = 1
# If page request (9999) is out of range, deliver last page of results.
try:
postcard_page = postcard_paginator.page(page)
except (EmptyPage, InvalidPage):
postcard_page = postcard_paginator.page(postcard_paginator.num_pages)
context['postcards_paginated'] = postcard_page
return render(request, 'postcards/browse.html', context)