magic-removal: Negligible formatting cleanups in django/db/models

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2017 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-01-16 23:11:12 +00:00
parent f2370573bc
commit 1eacb0f6ed
7 changed files with 15 additions and 28 deletions

View File

@ -1,29 +1,21 @@
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured
from django.core import validators
from django.db import backend, connection
from django.utils.functional import curry
from django.utils.text import capfirst
from django.db.models.loading import get_installed_models, get_installed_model_modules
from django.db.models.query import Q
from django.db.models.manager import Manager
from django.db.models.base import Model, AdminOptions
from django.db.models.fields import *
from django.db.models.fields.related import *
from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured
from django.db.models.exceptions import FieldDoesNotExist, BadKeywordArguments
from django.db.models import signals
from django.utils.functional import curry
from django.utils.text import capfirst
# Admin stages.
ADD, CHANGE, BOTH = 1, 2, 3
#def get_module(app_label, module_name):
# return __import__('%s.%s.%s' % (MODEL_PREFIX, app_label, module_name), '', '', [''])
def get_models(app):
models = []
get_models_helper(app, models)

View File

@ -5,4 +5,4 @@ class BadKeywordArguments(Exception):
pass
class BadCommand(Exception):
pass
pass

View File

@ -23,7 +23,7 @@ def add_model_module(mod, modules):
if hasattr(mod, '_MODELS'):
modules.append(mod)
for name in getattr(mod, '__all__', []):
submod = __import__("%s.%s" % ( mod.__name__, name),'','',[''])
submod = __import__("%s.%s" % (mod.__name__, name), '', '', [''])
add_model_module(submod, modules)
def get_installed_model_modules(core_models=None):

View File

@ -191,7 +191,7 @@ class Manager(object):
def get_in_bulk(self, id_list, *args, **kwargs):
assert isinstance(id_list, list), "get_in_bulk() must be provided with a list of IDs."
assert id_list != [], "get_in_bulk() cannot be passed an empty ID list."
assert id_list != [], "get_in_bulk() cannot be passed an empty ID list."
kwargs['where'] = ["%s.%s IN (%s)" % (backend.quote_name(self.klass._meta.db_table), backend.quote_name(self.klass._meta.pk.column), ",".join(['%s'] * len(id_list)))]
kwargs['params'] = id_list
obj_list = self.get_list(*args, **kwargs)
@ -257,4 +257,4 @@ class ManagerDescriptor(object):
def __get__(self, instance, type=None):
if instance != None:
raise AttributeError, "Manager isn't accessible via %s instances" % type.__name__
return self.manager
return self.manager

View File

@ -15,7 +15,7 @@ get_verbose_name = lambda class_name: re.sub('([A-Z])', ' \\1', class_name).lowe
DEFAULT_NAMES = ('module_name', 'verbose_name', 'verbose_name_plural', 'db_table', 'ordering',
'unique_together', 'admin','where_constraints', 'exceptions', 'permissions',
'get_latest_by','order_with_respect_to', 'module_constants')
'get_latest_by', 'order_with_respect_to', 'module_constants')
class Options:
def __init__(self, meta):
@ -33,7 +33,6 @@ class Options:
self.order_with_respect_to = None
self.module_constants = {}
self.admin = None
self.meta = meta
self.pk = None
self.has_auto_field = False
@ -92,9 +91,6 @@ class Options:
def __repr__(self):
return '<Options for %s>' % self.module_name
# def get_model_module(self):
# return get_module(self.app_label, self.module_name)
def get_content_type_id(self):
"Returns the content-type ID for this object type."
if not hasattr(self, '_content_type_id'):

View File

@ -281,7 +281,7 @@ def lookup_inner(path, clause, value, opts, table, column):
join_column = new_opts.object_name.lower() + '_id'
intermediate_table = field.get_m2m_db_table(current_opts)
raise FieldFound()
raise FieldFound
# Does the name belong to a reverse defined many-to-many field?
field = find_field(name, current_opts.get_all_related_many_to_many_objects())
@ -297,7 +297,7 @@ def lookup_inner(path, clause, value, opts, table, column):
join_column = new_opts.object_name.lower() + '_id'
intermediate_table = field.field.get_m2m_db_table(new_opts)
raise FieldFound()
raise FieldFound
# Does the name belong to a one-to-many field?
field = find_field(name, opts.get_all_related_objects())
@ -310,7 +310,7 @@ def lookup_inner(path, clause, value, opts, table, column):
# 1-N fields MUST be joined, regardless of any other conditions.
join_required = True
raise FieldFound()
raise FieldFound
# Does the name belong to a one-to-one, many-to-one, or regular field?
field = find_field(name, current_opts.fields)
@ -321,7 +321,7 @@ def lookup_inner(path, clause, value, opts, table, column):
new_column = new_opts.pk.column
join_column = field.column
raise FieldFound()
raise FieldFound
except FieldFound: # Match found, loop has been shortcut.
pass

View File

@ -1,12 +1,11 @@
from django.db.models.manipulators import ManipulatorCollection
class RelatedManipulatorCollection(ManipulatorCollection):
def __init__(self,related, parent_name_parts , instance, follow):
name_parts = parent_name_parts + (related.var_name, )
def __init__(self, related, parent_name_parts, instance, follow):
name_parts = parent_name_parts + (related.var_name,)
self.instance = instance
self.related = related
super(RelatedManipulatorCollection, self).__init__(
related.model,follow,name_parts)
super(RelatedManipulatorCollection, self).__init__(related.model, follow, name_parts)
def _save_child(self, manip, parent_key):
setattr(manip.original_object, self.related.field.attname, parent_key)