stephenmcd/mezzanine — Issue #118: Duplicate keywords (for posts, etc) can't be removed (previous fix is broken)
Author: derkaderka
Created: 2012-01-04 04:40:50+00:00
State: open

There was insufficient testing of the fix in commit 7e359fa964de01f68d069fc1435459e960b79e78 for issue #116.
I wonder how it was submitted considered it's pretty much broken. The following stack trace comes from an exception occurring with the scenario described in issue #116, supposedly fixed by the commit.

So, again, for the record (and please don't close an issue until regression testing has been properly done to check if the fix works at all): for keywords in the text field of a post "blah, xyz" (note the preceding space for xyz), an attempt to remove *either* of them fails. The fix does not do what it is supposed to do (though apparently it *might* prevent new keywords from being entered incorrectly if they contain spaces) and leaves existent users with this problem in a completely unstable state (the database needs to be manually fixed, if anything).

What's the point of submitting a fix that not only doesn't work as advertised but also breaks backwards comaptibility in affected systems 100%?

I think the least current production users expect is to have a manage.py command to perform the transition and fix the keywords "dangling" in the database. That would be perfect if removing them in the admin worked, but it doesn't. Go figure.

Traceback (most recent call last):

File "/usr/lib64/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/usr/lib64/python2.7/site-packages/django/contrib/admin/options.py", line 307, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)

File "/usr/lib64/python2.7/site-packages/django/utils/decorators.py", line 93, in _wrapped_view
response = view_func(request, *args, **kwargs)

File "/usr/lib64/python2.7/site-packages/django/views/decorators/cache.py", line 79, in _wrapped_view_func
response = view_func(request, *args, **kwargs)

File "/usr/lib64/python2.7/site-packages/django/contrib/admin/sites.py", line 197, in inner
return view(request, *args, **kwargs)

File "/usr/lib64/python2.7/site-packages/django/utils/decorators.py", line 28, in _wrapper
return bound_func(*args, **kwargs)

File "/usr/lib64/python2.7/site-packages/django/utils/decorators.py", line 93, in _wrapped_view
response = view_func(request, *args, **kwargs)

File "/usr/lib64/python2.7/site-packages/django/utils/decorators.py", line 24, in bound_func
return func(self, *args2, **kwargs2)

File "/usr/lib64/python2.7/site-packages/django/db/transaction.py", line 217, in inner
res = func(*args, **kwargs)

File "/usr/lib64/python2.7/site-packages/django/contrib/admin/options.py", line 983, in change_view
form.save_m2m()

File "/usr/lib64/python2.7/site-packages/django/forms/models.py", line 82, in save_m2m
f.save_form_data(instance, cleaned_data[f.name])

File "/usr/lib64/python2.7/site-packages/Mezzanine-0.12.4-py2.7.egg/mezzanine/generic/fields.py", line 172, in save_form_data
super(KeywordsField, self).save_form_data(instance, data)

File "/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", line 416, in save_form_data
setattr(instance, self.name, data)

File "/usr/lib64/python2.7/site-packages/django/contrib/contenttypes/generic.py", line 241, in __set__
manager.add(obj)

File "/usr/lib64/python2.7/site-packages/django/contrib/contenttypes/generic.py", line 282, in add
obj.save()

File "/usr/lib64/python2.7/site-packages/Mezzanine-0.12.4-py2.7.egg/mezzanine/core/models.py", line 251, in save
super(Orderable, self).save(*args, **kwargs)

File "/usr/lib64/python2.7/site-packages/django/db/models/base.py", line 460, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)

File "/usr/lib64/python2.7/site-packages/django/db/models/base.py", line 543, in save_base
for f in meta.local_fields if not isinstance(f, AutoField)]

File "/usr/lib64/python2.7/site-packages/django/db/models/fields/subclassing.py", line 28, in inner
return func(*args, **kwargs)

File "/usr/lib64/python2.7/site-packages/django/db/models/fields/related.py", line 876, in get_db_prep_save
connection=connection)

File "/usr/lib64/python2.7/site-packages/django/db/models/fields/subclassing.py", line 28, in inner
return func(*args, **kwargs)

File "/usr/lib64/python2.7/site-packages/django/db/models/fields/subclassing.py", line 28, in inner
return func(*args, **kwargs)

File "/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", line 276, in get_db_prep_save
return self.get_db_prep_value(value, connection=connection, prepared=False)

File "/usr/lib64/python2.7/site-packages/django/db/models/fields/subclassing.py", line 53, in inner
return func(*args, **kwargs)

File "/usr/lib64/python2.7/site-packages/django/db/models/fields/subclassing.py", line 53, in inner
return func(*args, **kwargs)

File "/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", line 271, in get_db_prep_value
value = self.get_prep_value(value)

File "/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", line 479, in get_prep_value
return int(value)

ValueError: invalid literal for int() with base 10: '|'