本文整理汇总了Python中stoqlib.database.queryexecuter.QueryExecuter.set_limit方法的典型用法代码示例。如果您正苦于以下问题:Python QueryExecuter.set_limit方法的具体用法?Python QueryExecuter.set_limit怎么用?Python QueryExecuter.set_limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.database.queryexecuter.QueryExecuter
的用法示例。
在下文中一共展示了QueryExecuter.set_limit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_query_executer
# 需要导入模块: from stoqlib.database.queryexecuter import QueryExecuter [as 别名]
# 或者: from stoqlib.database.queryexecuter.QueryExecuter import set_limit [as 别名]
def get_query_executer(self):
"""
Fetchs the QueryExecuter for the SearchContainer
:returns: a querty executer
:rtype: a :class:`QueryExecuter` subclass
"""
if self._query_executer is None:
executer = QueryExecuter(self.store)
if not self._lazy_search:
executer.set_limit(sysparam.get_int('MAX_SEARCH_RESULTS'))
if self._search_spec is not None:
executer.set_search_spec(self._search_spec)
self._query_executer = executer
return self._query_executer
示例2: SearchDialog
# 需要导入模块: from stoqlib.database.queryexecuter import QueryExecuter [as 别名]
# 或者: from stoqlib.database.queryexecuter.QueryExecuter import set_limit [as 别名]
class SearchDialog(BasicDialog):
""" Base class for *all* the search dialogs, responsible for the list
construction and "Filter" and "Clear" buttons management.
This class must be subclassed and its subclass *must* implement the methods
'get_columns' and 'get_query_and_args' (if desired, 'get_query_and_args'
can be implemented in the user's slave class, so SearchDialog will get its
slave instance and call the method directly). Its subclass also must
implement a setup_slaves method and call its equivalent base class method
as in:
>>> def setup_slave(self):
... SearchDialog.setup_slaves(self)
or then, call it in its constructor, like:
>>> def __init__(self, *args):
... SearchDialog.__init__(self)
"""
main_label_text = ''
#: Title that will appear in the window, for instance 'Product Search'
title = ''
# The table type which we will query on to get the objects.
search_table = None
#: The label that will be used for the main filter in this dialog
search_label = None
#: Selection mode to use (if its possible to select more than one row)
selection_mode = gtk.SELECTION_BROWSE
#: Default size for this dialog
size = ()
#: If the advanced search is enabled or disabled. When ``True`` we will
#: instrospect the columns returned by :meth:`get_columns`,and use those
#: that are subclasses of :class:`stoqlib.gui.columns.SearchColumn` to add
#: as options for the user to filter the results.
advanced_search = True
tree = False
def __init__(self, store, search_table=None, hide_footer=True,
title='', selection_mode=None, double_click_confirm=False):
"""
A base class for search dialog inheritance
:param store: a store
:param table:
:param search_table:
:param hide_footer:
:param title:
:param selection_mode:
:param double_click_confirm: If double click a item in the list should
automatically confirm
"""
self.store = store
self.search_table = search_table or self.search_table
if not self.search_table:
raise ValueError("%r needs a search table" % self)
self.selection_mode = self._setup_selection_mode(selection_mode)
self.summary_label = None
self.double_click_confirm = double_click_confirm
BasicDialog.__init__(self, hide_footer=hide_footer,
main_label_text=self.main_label_text,
title=title or self.title,
size=self.size)
self.executer = QueryExecuter(store)
# FIXME: Remove this limit, but we need to migrate all existing
# searches to use lazy lists first. That in turn require
# us to rewrite the queries in such a way that count(*)
# will work properly.
self.executer.set_limit(sysparam(self.store).MAX_SEARCH_RESULTS)
self.set_table(self.search_table)
self.enable_window_controls()
self.disable_ok()
self.set_ok_label(_('Se_lect Items'))
self._setup_search()
self._setup_details_slave()
self.create_filters()
self.setup_widgets()
if self.search_label:
self.set_searchbar_label(self.search_label)
def _setup_selection_mode(self, selection_mode):
# For consistency do not allow none or single, in other words,
# only allowed values are browse and multiple so we always will
# be able to use both the keyboard and the mouse to select items
# in the search list.
selection_mode = selection_mode or self.selection_mode
if (selection_mode != gtk.SELECTION_BROWSE and
selection_mode != gtk.SELECTION_MULTIPLE):
raise ValueError('Invalid selection mode %r' % selection_mode)
#.........这里部分代码省略.........