summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-08-10 03:12:37 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-08-10 03:12:37 +0000
commit258e6bc33034b755a6c94cfa22b6ee44b1494501 (patch)
treed6f1f0b410dbe406dc924ede9c7056db4b0aef2d
parent0d060ba547e5cfd722e673637d61bac550cc5b00 (diff)
Simplified metasystem get_db_prep_save() hook so that it doesn't take an 'add' parameter -- it wasn't being used, anyway.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@454 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/meta/__init__.py4
-rw-r--r--django/core/meta/fields.py14
2 files changed, 9 insertions, 9 deletions
diff --git a/django/core/meta/__init__.py b/django/core/meta/__init__.py
index 52572053f1..c6bcb09e4b 100644
--- a/django/core/meta/__init__.py
+++ b/django/core/meta/__init__.py
@@ -720,7 +720,7 @@ def method_save(opts, self):
add = not bool(getattr(self, opts.pk.name))
for f in non_pks:
f.pre_save(self, getattr(self, f.name), add)
- db_values = [f.get_db_prep_save(getattr(self, f.name), add) for f in non_pks]
+ db_values = [f.get_db_prep_save(getattr(self, f.name)) for f in non_pks]
# OneToOne objects are a special case because there's no AutoField, and the
# primary key field is set manually.
if isinstance(opts.pk.rel, OneToOne):
@@ -732,7 +732,7 @@ def method_save(opts, self):
placeholders = ['%s'] * len(field_names)
cursor.execute("INSERT INTO %s (%s) VALUES (%s)" % \
(opts.db_table, ','.join(field_names), ','.join(placeholders)),
- [f.get_db_prep_save(getattr(self, f.name), add=True) for f in opts.fields])
+ [f.get_db_prep_save(getattr(self, f.name)) for f in opts.fields])
else:
if not add:
cursor.execute("UPDATE %s SET %s WHERE %s=%%s" % \
diff --git a/django/core/meta/fields.py b/django/core/meta/fields.py
index b90877a54b..34027a8d7a 100644
--- a/django/core/meta/fields.py
+++ b/django/core/meta/fields.py
@@ -89,7 +89,7 @@ class Field(object):
"""
pass
- def get_db_prep_save(self, value, add):
+ def get_db_prep_save(self, value):
"Returns field's value prepared for saving into a database."
return value
@@ -284,21 +284,21 @@ class DateField(Field):
if self.auto_now or (self.auto_now_add and add):
setattr(obj, self.name, datetime.datetime.now())
- def get_db_prep_save(self, value, add):
+ def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
if value is not None:
value = value.strftime('%Y-%m-%d')
- return Field.get_db_prep_save(self, value, add)
+ return Field.get_db_prep_save(self, value)
def get_manipulator_field_objs(self):
return [formfields.DateField]
class DateTimeField(DateField):
- def get_db_prep_save(self, value, add):
+ def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
if value is not None:
value = value.strftime('%Y-%m-%d %H:%M:%S')
- return Field.get_db_prep_save(self, value, add)
+ return Field.get_db_prep_save(self, value)
def get_manipulator_field_objs(self):
return [formfields.DateField, formfields.TimeField]
@@ -487,11 +487,11 @@ class TimeField(Field):
if self.auto_now or (self.auto_now_add and add):
setattr(obj, self.name, datetime.datetime.now().time())
- def get_db_prep_save(self, value, add):
+ def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
if value is not None:
value = value.strftime('%H:%M:%S')
- return Field.get_db_prep_save(self, value, add)
+ return Field.get_db_prep_save(self, value)
def get_manipulator_field_objs(self):
return [formfields.TimeField]