本文整理汇总了Python中invenio.config.CFG_SITE_URL.find方法的典型用法代码示例。如果您正苦于以下问题:Python CFG_SITE_URL.find方法的具体用法?Python CFG_SITE_URL.find怎么用?Python CFG_SITE_URL.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invenio.config.CFG_SITE_URL
的用法示例。
在下文中一共展示了CFG_SITE_URL.find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: guess_collection_of_a_record
# 需要导入模块: from invenio.config import CFG_SITE_URL [as 别名]
# 或者: from invenio.config.CFG_SITE_URL import find [as 别名]
def guess_collection_of_a_record(recID, referer=None, recreate_cache_if_needed=True):
"""Return collection name a record recid belongs to, by first testing
the referer URL if provided and otherwise returning the
primary collection."""
if referer:
dummy, hostname, path, dummy, query, dummy = urlparse.urlparse(referer)
# requests can come from different invenio installations, with
# different collections
if CFG_SITE_URL.find(hostname) < 0:
return guess_primary_collection_of_a_record(recID)
g = _re_collection_url.match(path)
if g:
name = urllib.unquote_plus(g.group(1))
# check if this collection actually exist (also normalize the name
# if case-insensitive)
name = Collection.query.filter_by(name=name).value('name')
if name and recID in get_collection_reclist(name):
return name
elif path.startswith('/search'):
if recreate_cache_if_needed:
collection_reclist_cache.recreate_cache_if_needed()
query = cgi.parse_qs(query)
for name in query.get('cc', []) + query.get('c', []):
name = Collection.query.filter_by(name=name).value('name')
if name and recID in get_collection_reclist(name, recreate_cache_if_needed=False):
return name
return guess_primary_collection_of_a_record(recID)