本文整理汇总了Python中common.selection.Selection.species方法的典型用法代码示例。如果您正苦于以下问题:Python Selection.species方法的具体用法?Python Selection.species怎么用?Python Selection.species使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.selection.Selection
的用法示例。
在下文中一共展示了Selection.species方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_context_data
# 需要导入模块: from common.selection import Selection [as 别名]
# 或者: from common.selection.Selection import species [as 别名]
def get_context_data(self, **kwargs):
"""get context from parent class (really only relevant for children of this class, as TemplateView does
not have any context variables)"""
context = super().get_context_data(**kwargs)
# get selection from session and add to context
# get simple selection from session
simple_selection = self.request.session.get('selection', False)
# create full selection and import simple selection (if it exists)
selection = Selection()
# on the first page of a workflow, clear the selection (or dont' import from the session)
if self.step is not 1:
if simple_selection:
selection.importer(simple_selection)
# default species selection
if self.default_species:
sp = Species.objects.get(common_name=self.default_species)
o = SelectionItem('species', sp)
selection.species = [o]
# update session
simple_selection = selection.exporter()
self.request.session['selection'] = simple_selection
context['selection'] = {}
for selection_box, include in self.selection_boxes.items():
if include:
context['selection'][selection_box] = selection.dict(selection_box)['selection'][selection_box]
if self.filters:
context['selection']['species'] = selection.species
context['selection']['annotation'] = selection.annotation
context['selection']['g_proteins'] = selection.g_proteins
context['selection']['pref_g_proteins'] = selection.pref_g_proteins
# get attributes of this class and add them to the context
attributes = inspect.getmembers(self, lambda a:not(inspect.isroutine(a)))
for a in attributes:
if not(a[0].startswith('__') and a[0].endswith('__')):
context[a[0]] = a[1]
return context