Commits

Esteban Feldman  committed 5e3df21

catching tag length error when saving

  • Participants
  • Parent commits b3a22fd

Comments (0)

Files changed (1)

File tagged/__init__.py

 from django.db.models.signals import post_save
 from django.conf import settings
+from django.db import transaction
 
 import tagging
 
     
 registry = {}
 
+@transaction.commit_manually
 def process_tags(*args, **kwargs):
     sender = kwargs['sender']
     instance = kwargs['instance']
                     " a string type." % (fieldname, sender._meta.object_name))
             tags = processor.process(field_data, use_zemanta)
             if tags:
-                instance.tags = tags
+                try:
+                    # since the maximum for a tag is 50 chars we should
+                    # be careful on it
+                    instance.tags = tags
+                except:
+                    transaction.rollback()
+                    # TODO: log this
+                    # an error with the length of the tags here
+                    # no more than 50 chars
+                else:
+                    transaction.commit()
 
 
 def register(model, fields,