crs4 / notredam

Automatically exported from code.google.com/p/notredam
http://www.notredam.org
17 stars 4 forks source link

Repository save fails due to additional using= parameter #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When using the latest Django trunk, uploading fails due to an additional
parameter "using=db" being passed to the model.save() method. The following
patch corrects this.

diff -r 9cad5974e732 src/dam/repository/models.py
--- a/src/dam/repository/models.py      Fri Apr 23 17:20:25 2010 +0200
+++ b/src/dam/repository/models.py      Tue Apr 27 14:48:25 2010 +0200
@@ -154,11 +154,11 @@

     ID = property(fget=_get_id)

-    def save(self, force_insert=False):
+    def save(self, force_insert=False, **kwargs):
         if self._id == '':
             self._id = 'a' + sha.new(str(random.random())).hexdigest()
         try:
-            models.Model.save(self, force_insert=force_insert)
+            models.Model.save(self, force_insert=force_insert, **kwargs)
         except:
             self._id = ''
             raise

Original issue reported on code.google.com by dotsph...@gmail.com on 27 Apr 2010 at 12:50

GoogleCodeExporter commented 9 years ago
We are still working on Django 1.1, so we have not met this problem yet. Thanks 
for the patch anyway. 
Usually when I ovveride models methods i prefer to use *args and **kwargs, in 
this way:

def save(self, *args, **kwargs):
    models.Model.save(self,*args, **kwargs)

It should work also in this case.

Original comment by mdrio1...@gmail.com on 31 Jan 2011 at 3:08

GoogleCodeExporter commented 9 years ago

Original comment by maurizio...@gmail.com on 31 Jan 2011 at 3:26

GoogleCodeExporter commented 9 years ago

Original comment by maurizio...@gmail.com on 31 Jan 2011 at 3:26

GoogleCodeExporter commented 9 years ago

Original comment by maurizio...@gmail.com on 14 Jun 2011 at 9:39