当前位置: 首页>>代码示例>>Python>>正文


Python ModelResource.get_object_list方法代码示例

本文整理汇总了Python中tastypie.resources.ModelResource.get_object_list方法的典型用法代码示例。如果您正苦于以下问题:Python ModelResource.get_object_list方法的具体用法?Python ModelResource.get_object_list怎么用?Python ModelResource.get_object_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tastypie.resources.ModelResource的用法示例。


在下文中一共展示了ModelResource.get_object_list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_object_list

# 需要导入模块: from tastypie.resources import ModelResource [as 别名]
# 或者: from tastypie.resources.ModelResource import get_object_list [as 别名]
 def get_object_list(self, request):
     ''' Method to return the list of objects via GET method to the Resource (not concrete).
     If the variable 'search_type' is present returns the appropriate bundles
     which match the searching query. 'search_type' can have several values:
         'name' - accompanied by 'q_str' variable containing the search string
                  returns all Bundles containing the q_str in their name.
         'id' - accompanied by 'q_str' variable containing the search string
                        returns all Bundles containing a record that contains the q_str in their name.
         'type' - accompanied by 'q_str' variable containing the search string
                       returns all Bundles containing a literal attribute with type prov:type
                       and value containing q_str.
         'time' - accompanied by 'start' and/or 'end' variable containing the times
                       returns all Bundles with within the time frame [strat:end]
         'any' - accompanied by 'q_str' variable containing the search string
                  returns all Bundles containing anything matching q_str.
     '''
     
     search_type = request.GET.get('search_type', None)
     if not search_type:    
         return ModelResource.get_object_list(self, request)
     try:
         if search_type == 'name':
             result = search_name(request.GET.get('q_str', None))
         elif search_type == 'id':
             result = search_id(request.GET.get('q_str', None))
         elif search_type == 'type':
             result = search_literal(request.GET.get('literal', None) + 'prov#type', request.GET.get('q_str', None))
         elif search_type == 'time': 
             result = search_timeframe(request.GET.get('start', None), request.GET.get('end', None))
         elif search_type == 'any':
             result = search_any_text_field(request.GET.get('q_str', None))
         else:
             raise ImmediateHttpResponse(HttpBadRequest())
         return result
     except:
         raise ImmediateHttpResponse(HttpBadRequest())
开发者ID:YilinHao,项目名称:w3-prov,代码行数:38,代码来源:api.py


注:本文中的tastypie.resources.ModelResource.get_object_list方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。