magic-removal: Added 'core_filters' attribute to Manager -- a dictionary of core filters to apply to every database query made with that manager.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2140 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
a35f7c6e15
commit
a6139af645
|
@ -26,6 +26,9 @@ class Manager(object):
|
|||
# Tracks each time a Manager instance is created. Used to retain order.
|
||||
creation_counter = 0
|
||||
|
||||
# Dictionary of lookup parameters to apply to every _get_sql_clause().
|
||||
core_filters = {}
|
||||
|
||||
def __init__(self):
|
||||
# Increase the creation counter, and save our local copy.
|
||||
self.creation_counter = Manager.creation_counter
|
||||
|
@ -56,6 +59,9 @@ class Manager(object):
|
|||
|
||||
opts = self.klass._meta
|
||||
|
||||
# Apply core filters.
|
||||
kwargs.update(self.core_filters)
|
||||
|
||||
# Construct the fundamental parts of the query: SELECT X FROM Y WHERE Z.
|
||||
select = ["%s.%s" % (backend.quote_name(opts.db_table), backend.quote_name(f.column)) for f in opts.fields]
|
||||
tables = (kwargs.get('tables') and [quote_only_if_word(t) for t in kwargs['tables']] or [])
|
||||
|
|
Loading…
Reference in New Issue