Skip to content

Commit

Permalink
magic-removal: Merged to [2343]
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2344 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Feb 18, 2006
1 parent 6589992 commit 77a0a94
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ answer newbie questions, and generally made Django that much better:
Robert Rock Howard <http://djangomojo.com/> Robert Rock Howard <http://djangomojo.com/>
Jason Huggins <http://www.jrandolph.com/blog/> Jason Huggins <http://www.jrandolph.com/blog/>
Michael Josephson <http://www.sdjournal.com/> Michael Josephson <http://www.sdjournal.com/>
junzhang.jn@gmail.com
Russell Keith-Magee <freakboy@iinet.net.au> Russell Keith-Magee <freakboy@iinet.net.au>
Garth Kidd <http://www.deadlybloodyserious.com/> Garth Kidd <http://www.deadlybloodyserious.com/>
Sune Kirkeby <http://ibofobi.dk/> Sune Kirkeby <http://ibofobi.dk/>
Expand Down
12 changes: 10 additions & 2 deletions django/contrib/syndication/feeds.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@ def __get_dynamic_attr(self, attname, obj, default=None):
except AttributeError: except AttributeError:
return default return default
if callable(attr): if callable(attr):
try: # Check func_code.co_argcount rather than try/excepting the
# function and catching the TypeError, because something inside
# the function may raise the TypeError. This technique is more
# accurate.
if hasattr(attr, 'func_code'):
argcount = attr.func_code.co_argcount
else:
argcount = attr.__call__.func_code.co_argcount
if argcount == 2: # one argument is 'self'
return attr(obj) return attr(obj)
except TypeError: else:
return attr() return attr()
return attr return attr


Expand Down
11 changes: 5 additions & 6 deletions django/db/models/fields/related.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _add_m2m_items(rel_manager_inst, managerclass, rel_model, join_table, this_c
# rel_manager_inst: the RelatedManager instance # rel_manager_inst: the RelatedManager instance
# managerclass: class that can create and save new objects # managerclass: class that can create and save new objects
# rel_model: the model class of the 'related' object # rel_model: the model class of the 'related' object
# join_table: name of the m2m link table # join_table: name of the m2m link table
# this_col_name: the PK colname in join_table for 'this' object # this_col_name: the PK colname in join_table for 'this' object
# rel_col_name: the PK colname in join_table for the related object # rel_col_name: the PK colname in join_table for the related object
# this_pk_val: the primary key for 'this' object # this_pk_val: the primary key for 'this' object
Expand All @@ -125,7 +125,7 @@ def _add_m2m_items(rel_manager_inst, managerclass, rel_model, join_table, this_c
cursor = connection.cursor() cursor = connection.cursor()
cursor.execute("SELECT %s FROM %s WHERE %s = %%s AND %s IN (%s)" % \ cursor.execute("SELECT %s FROM %s WHERE %s = %%s AND %s IN (%s)" % \
(rel_col_name, join_table, this_col_name, (rel_col_name, join_table, this_col_name,
rel_col_name, ",".join(['%s'] * len(new_ids))), rel_col_name, ",".join(['%s'] * len(new_ids))),
[this_pk_val] + list(new_ids)) [this_pk_val] + list(new_ids))
if cursor.rowcount is not None and cursor.rowcount > 0: if cursor.rowcount is not None and cursor.rowcount > 0:
existing_ids = set([row[0] for row in cursor.fetchmany(cursor.rowcount)]) existing_ids = set([row[0] for row in cursor.fetchmany(cursor.rowcount)])
Expand All @@ -144,7 +144,7 @@ def _remove_m2m_items(rel_model, join_table, this_col_name,
# Utility function used by the ManyRelatedObjectsDescriptors # Utility function used by the ManyRelatedObjectsDescriptors
# to do removal from a many-to-many field. # to do removal from a many-to-many field.
# rel_model: the model class of the 'related' object # rel_model: the model class of the 'related' object
# join_table: name of the m2m link table # join_table: name of the m2m link table
# this_col_name: the PK colname in join_table for 'this' object # this_col_name: the PK colname in join_table for 'this' object
# rel_col_name: the PK colname in join_table for the related object # rel_col_name: the PK colname in join_table for the related object
# this_pk_val: the primary key for 'this' object # this_pk_val: the primary key for 'this' object
Expand All @@ -166,7 +166,7 @@ def _remove_m2m_items(rel_model, join_table, this_col_name,
def _clear_m2m_items(join_table, this_col_name, this_pk_val): def _clear_m2m_items(join_table, this_col_name, this_pk_val):
# Utility function used by the ManyRelatedObjectsDescriptors # Utility function used by the ManyRelatedObjectsDescriptors
# to clear all from a many-to-many field. # to clear all from a many-to-many field.
# join_table: name of the m2m link table # join_table: name of the m2m link table
# this_col_name: the PK colname in join_table for 'this' object # this_col_name: the PK colname in join_table for 'this' object
# this_pk_val: the primary key for 'this' object # this_pk_val: the primary key for 'this' object
from django.db import connection from django.db import connection
Expand Down Expand Up @@ -311,10 +311,9 @@ def __init__(self, to, to_field=None, **kwargs):
to_name = to._meta.object_name.lower() to_name = to._meta.object_name.lower()
except AttributeError: # to._meta doesn't exist, so it must be RECURSIVE_RELATIONSHIP_CONSTANT except AttributeError: # to._meta doesn't exist, so it must be RECURSIVE_RELATIONSHIP_CONSTANT
assert isinstance(to, basestring), "ForeignKey(%r) is invalid. First parameter to ForeignKey must be either a model, a model name, or the string %r" % (to, RECURSIVE_RELATIONSHIP_CONSTANT) assert isinstance(to, basestring), "ForeignKey(%r) is invalid. First parameter to ForeignKey must be either a model, a model name, or the string %r" % (to, RECURSIVE_RELATIONSHIP_CONSTANT)
kwargs['verbose_name'] = kwargs.get('verbose_name', '')
else: else:
to_field = to_field or to._meta.pk.name to_field = to_field or to._meta.pk.name
kwargs['verbose_name'] = kwargs.get('verbose_name', to._meta.verbose_name) kwargs['verbose_name'] = kwargs.get('verbose_name', '')


if kwargs.has_key('edit_inline_type'): if kwargs.has_key('edit_inline_type'):
import warnings import warnings
Expand Down

0 comments on commit 77a0a94

Please sign in to comment.