From a6139af6450144d99e990833be766356ede125e6 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 27 Jan 2006 23:42:45 +0000 Subject: [PATCH] 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 --- django/db/models/manager.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/django/db/models/manager.py b/django/db/models/manager.py index 9bc3ab1b62..07f6a28172 100644 --- a/django/db/models/manager.py +++ b/django/db/models/manager.py @@ -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 [])