mirror of
https://github.com/django/django.git
synced 2025-07-05 18:29:11 +00:00
[soc2009/multidb] Removed _meta.using. This shouldn't be a model-level property. Patch from Russell Keith-Magee.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11770 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
da909ae3a0
commit
f0b8874479
1
TODO
1
TODO
@ -10,7 +10,6 @@ Required for v1.2
|
|||||||
* Resolve the public facing UI issues around using multi-db
|
* Resolve the public facing UI issues around using multi-db
|
||||||
* Should we take the opportunity to modify DB backends to use fully qualified paths?
|
* Should we take the opportunity to modify DB backends to use fully qualified paths?
|
||||||
* Should we clean up DATABASES['DATABASE_NAME'] to DATABASES['NAME'] etc?
|
* Should we clean up DATABASES['DATABASE_NAME'] to DATABASES['NAME'] etc?
|
||||||
* Meta.using? Is is still required/desirable?
|
|
||||||
* Cleanup of new API entry points
|
* Cleanup of new API entry points
|
||||||
* validate() on a field
|
* validate() on a field
|
||||||
* name/purpose clash with Honza?
|
* name/purpose clash with Honza?
|
||||||
|
@ -438,7 +438,7 @@ class Model(object):
|
|||||||
need for overrides of save() to pass around internal-only parameters
|
need for overrides of save() to pass around internal-only parameters
|
||||||
('raw', 'cls', and 'origin').
|
('raw', 'cls', and 'origin').
|
||||||
"""
|
"""
|
||||||
using = using or self._state.db or self._meta.using or DEFAULT_DB_ALIAS
|
using = using or self._state.db or DEFAULT_DB_ALIAS
|
||||||
connection = connections[using]
|
connection = connections[using]
|
||||||
assert not (force_insert and force_update)
|
assert not (force_insert and force_update)
|
||||||
if cls is None:
|
if cls is None:
|
||||||
@ -591,7 +591,7 @@ class Model(object):
|
|||||||
parent_obj._collect_sub_objects(seen_objs)
|
parent_obj._collect_sub_objects(seen_objs)
|
||||||
|
|
||||||
def delete(self, using=None):
|
def delete(self, using=None):
|
||||||
using = using or self._state.db or self._meta.using or DEFAULT_DB_ALIAS
|
using = using or self._state.db or DEFAULT_DB_ALIAS
|
||||||
connection = connections[using]
|
connection = connections[using]
|
||||||
assert self._get_pk_val() is not None, "%s object can't be deleted because its %s attribute is set to None." % (self._meta.object_name, self._meta.pk.attname)
|
assert self._get_pk_val() is not None, "%s object can't be deleted because its %s attribute is set to None." % (self._meta.object_name, self._meta.pk.attname)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ get_verbose_name = lambda class_name: re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|
|
|||||||
DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering',
|
DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering',
|
||||||
'unique_together', 'permissions', 'get_latest_by',
|
'unique_together', 'permissions', 'get_latest_by',
|
||||||
'order_with_respect_to', 'app_label', 'db_tablespace',
|
'order_with_respect_to', 'app_label', 'db_tablespace',
|
||||||
'abstract', 'managed', 'proxy', 'using', 'auto_created')
|
'abstract', 'managed', 'proxy', 'auto_created')
|
||||||
|
|
||||||
class Options(object):
|
class Options(object):
|
||||||
def __init__(self, meta, app_label=None):
|
def __init__(self, meta, app_label=None):
|
||||||
@ -47,7 +47,6 @@ class Options(object):
|
|||||||
self.proxy_for_model = None
|
self.proxy_for_model = None
|
||||||
self.parents = SortedDict()
|
self.parents = SortedDict()
|
||||||
self.duplicate_targets = {}
|
self.duplicate_targets = {}
|
||||||
self.using = None
|
|
||||||
self.auto_created = False
|
self.auto_created = False
|
||||||
|
|
||||||
# To handle various inheritance situations, we need to track where
|
# To handle various inheritance situations, we need to track where
|
||||||
|
@ -25,20 +25,14 @@ class QuerySet(object):
|
|||||||
"""
|
"""
|
||||||
Represents a lazy database lookup for a set of objects.
|
Represents a lazy database lookup for a set of objects.
|
||||||
"""
|
"""
|
||||||
def __init__(self, model=None, query=None):
|
def __init__(self, model=None, query=None, using=None):
|
||||||
self.model = model
|
self.model = model
|
||||||
# EmptyQuerySet instantiates QuerySet with model as None
|
# EmptyQuerySet instantiates QuerySet with model as None
|
||||||
if model:
|
self.db = using or DEFAULT_DB_ALIAS
|
||||||
using = model._meta.using
|
|
||||||
else:
|
|
||||||
using = None
|
|
||||||
using = using or DEFAULT_DB_ALIAS
|
|
||||||
connection = connections[using]
|
|
||||||
self.query = query or sql.Query(self.model)
|
self.query = query or sql.Query(self.model)
|
||||||
self._result_cache = None
|
self._result_cache = None
|
||||||
self._iter = None
|
self._iter = None
|
||||||
self._sticky_filter = False
|
self._sticky_filter = False
|
||||||
self.db = using
|
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# PYTHON MAGIC METHODS #
|
# PYTHON MAGIC METHODS #
|
||||||
|
@ -4,8 +4,9 @@
|
|||||||
Model ``Meta`` options
|
Model ``Meta`` options
|
||||||
======================
|
======================
|
||||||
|
|
||||||
This document explains all the possible :ref:`metadata options <meta-options>` that you can give your model in its internal
|
This document explains all the possible :ref:`metadata options
|
||||||
``class Meta``.
|
<meta-options>` that you can give your model in its internal ``class
|
||||||
|
Meta``.
|
||||||
|
|
||||||
Available ``Meta`` options
|
Available ``Meta`` options
|
||||||
==========================
|
==========================
|
||||||
@ -220,17 +221,6 @@ set of fields::
|
|||||||
|
|
||||||
unique_together = ("driver", "restaurant")
|
unique_together = ("driver", "restaurant")
|
||||||
|
|
||||||
``using``
|
|
||||||
---------
|
|
||||||
|
|
||||||
.. attribute:: Options.using
|
|
||||||
|
|
||||||
The alias for the default database to be used for this model. If this is not
|
|
||||||
provided the default is ``'default'``. If it is porvided it can be overidden
|
|
||||||
at the ``QuerySet`` level with the ``using()`` method.
|
|
||||||
|
|
||||||
.. versionadded:: 1.2
|
|
||||||
|
|
||||||
``verbose_name``
|
``verbose_name``
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user