Renamed OneToOne to OneToOneRel to be consistent with ManyToManyRel

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2650 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-04-10 03:35:56 +00:00
parent b8d8aca5fd
commit b9e40b14bc
4 changed files with 7 additions and 7 deletions

View File

@ -560,7 +560,7 @@ def _get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current
continue continue
opts_seen.append(related.opts) opts_seen.append(related.opts)
rel_opts_name = related.get_method_name_part() rel_opts_name = related.get_method_name_part()
if isinstance(related.field.rel, meta.OneToOne): if isinstance(related.field.rel, meta.OneToOneRel):
try: try:
sub_obj = getattr(obj, 'get_%s' % rel_opts_name)() sub_obj = getattr(obj, 'get_%s' % rel_opts_name)()
except ObjectDoesNotExist: except ObjectDoesNotExist:

View File

@ -410,7 +410,7 @@ class Options:
# Calculate one_to_one_field. # Calculate one_to_one_field.
self.one_to_one_field = None self.one_to_one_field = None
for f in self.fields: for f in self.fields:
if isinstance(f.rel, OneToOne): if isinstance(f.rel, OneToOneRel):
self.one_to_one_field = f self.one_to_one_field = f
break break
# Cache the primary-key field. # Cache the primary-key field.
@ -1038,7 +1038,7 @@ def method_delete(opts, self):
cursor = db.db.cursor() cursor = db.db.cursor()
for related in opts.get_all_related_objects(): for related in opts.get_all_related_objects():
rel_opts_name = related.get_method_name_part() rel_opts_name = related.get_method_name_part()
if isinstance(related.field.rel, OneToOne): if isinstance(related.field.rel, OneToOneRel):
try: try:
sub_obj = getattr(self, 'get_%s' % rel_opts_name)() sub_obj = getattr(self, 'get_%s' % rel_opts_name)()
except ObjectDoesNotExist: except ObjectDoesNotExist:

View File

@ -133,7 +133,7 @@ class Field(object):
# Set db_index to True if the field has a relationship and doesn't explicitly set db_index. # Set db_index to True if the field has a relationship and doesn't explicitly set db_index.
if db_index is None: if db_index is None:
if isinstance(rel, OneToOne) or isinstance(rel, ManyToOneRel): if isinstance(rel, OneToOneRel) or isinstance(rel, ManyToOneRel):
self.db_index = True self.db_index = True
else: else:
self.db_index = False self.db_index = False
@ -811,7 +811,7 @@ class OneToOneField(IntegerField):
warnings.warn("edit_inline_type is deprecated. Use edit_inline instead.") warnings.warn("edit_inline_type is deprecated. Use edit_inline instead.")
kwargs['edit_inline'] = kwargs.pop('edit_inline_type') kwargs['edit_inline'] = kwargs.pop('edit_inline_type')
kwargs['rel'] = OneToOne(to, to_field, kwargs['rel'] = OneToOneRel(to, to_field,
num_in_admin=kwargs.pop('num_in_admin', 0), num_in_admin=kwargs.pop('num_in_admin', 0),
edit_inline=kwargs.pop('edit_inline', False), edit_inline=kwargs.pop('edit_inline', False),
related_name=kwargs.pop('related_name', None), related_name=kwargs.pop('related_name', None),
@ -855,7 +855,7 @@ class ManyToManyRel:
self.raw_id_admin = raw_id_admin self.raw_id_admin = raw_id_admin
assert not (self.raw_id_admin and self.filter_interface), "ManyToManyRels may not use both raw_id_admin and filter_interface" assert not (self.raw_id_admin and self.filter_interface), "ManyToManyRels may not use both raw_id_admin and filter_interface"
class OneToOne(ManyToOneRel): class OneToOneRel(ManyToOneRel):
def __init__(self, to, field_name, num_in_admin=0, edit_inline=False, def __init__(self, to, field_name, num_in_admin=0, edit_inline=False,
related_name=None, limit_choices_to=None, lookup_overrides=None, related_name=None, limit_choices_to=None, lookup_overrides=None,
raw_id_admin=False): raw_id_admin=False):

View File

@ -26,7 +26,7 @@ for mod in modules:
# generated. # generated.
rel_mod = related.opts.get_model_module() rel_mod = related.opts.get_model_module()
rel_obj_name = related.get_method_name_part() rel_obj_name = related.get_method_name_part()
if isinstance(related.field.rel, meta.OneToOne): if isinstance(related.field.rel, meta.OneToOneRel):
# Add "get_thingie" methods for one-to-one related objects. # Add "get_thingie" methods for one-to-one related objects.
# EXAMPLE: Place.get_restaurants_restaurant() # EXAMPLE: Place.get_restaurants_restaurant()
func = curry(meta.method_get_related, 'get_object', rel_mod, related.field) func = curry(meta.method_get_related, 'get_object', rel_mod, related.field)