本文整理汇总了Python中model.Member.search_member_from_document方法的典型用法代码示例。如果您正苦于以下问题:Python Member.search_member_from_document方法的具体用法?Python Member.search_member_from_document怎么用?Python Member.search_member_from_document使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Member
的用法示例。
在下文中一共展示了Member.search_member_from_document方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: members_with_status
# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import search_member_from_document [as 别名]
def members_with_status(self, status_name):
index = search.Index(name='members')
results = index.search(query=search.Query('status:' + status_name, options=search.QueryOptions(limit=LIMIT)))
ret = list()
for document in results:
ret.append(Member.search_member_from_document(document))
return ret
示例2: get
# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import search_member_from_document [as 别名]
def get(self):
template = JINJA_ENVIRONMENT.get_template('templates/members/member_list.html')
countries = Country.all().order('order').fetch(LIMIT)
statuses = Status.all().order('order').fetch(LIMIT)
types = MemberType.all().order('order').fetch(LIMIT)
# TODO: Make sensible
query_string = ''
current_search = self.request.get('search')
query_string += current_search
current_status = self.request.get('status')
if current_status != '':
if query_string != '':
query_string += ' AND '
query_string += 'status:' + current_status
current_type = self.request.get('type')
if current_type != '':
if query_string != '':
query_string += ' AND '
query_string += 'type:'+ current_type
current_country = self.request.get('country')
if current_country and current_country != '':
if query_string != '':
query_string += ' AND '
query_string += 'country:' + current_country
index = search.Index(name='members')
result = index.search(query=search.Query(query_string, options=search.QueryOptions(limit=LIMIT)))
members = list()
for document in result.results:
members.append(Member.search_member_from_document(document))
members = sorted(members, key=lambda x: x.number)
current_status_name = current_status
current_type_name = current_type
total = memcache.get('member_count')
if not total:
total = 0
data = {
'countries': countries,
'statuses': statuses,
'types': types,
'members': members,
'current_status': current_status,
'current_type': current_type,
'current_search': current_search,
'found': result.number_found,
'shown': len(members),
'total': total
}
self.response.write(template.render(data))