I have confirmed that it also works as expected with cx_Oracle-5.0.1 Woohoo
On Mar 24, 2:14 pm, Brandon Taylor <btaylordes...@gmail.com> wrote: > After much digging, I was able to find the problem. In fields.py in > django-tagging, the tags are pulled from cache when they are saved, > rather than going back to the database. > > The problem I was seeing wasn't that tags werent' being applied to > objects, or added to the database, but the input field was NOT > reflecting the changes to the tags. The cache was not being set with > the new values. > > So, I found a ticket on the tagging > site:http://code.google.com/p/django-tagging/issues/detail?id=28&can=1&q=c... > > Which has a patch, but that doesn't work for the svn checkout of > django-tagging. I changed the _post_init method to: > > #fields.py > def contribute_to_class(self, cls, name): > super(TagField, self).contribute_to_class(cls, name) > > # Make this object the descriptor for field access. > setattr(cls, self.name, self) > > # Save tags back to the database post-save > signals.post_save.connect(self._save, cls, True) > signals.post_init.connect(self._post_init, cls, True) #wire it > up here > > def _post_init(self, **kwargs): > instance = kwargs['instance'] > if instance._get_pk_val() is None: > self._set_instance_tag_cache(instance, '') > else: > self._set_instance_tag_cache(instance, edit_string_for_tags > (Tag.objects.get_for_object(instance))) > #this re-sets the tags from the database > > This caused some interesting behavior on the form field. Instead of > tags being separated by commas, and multi-word tags being enclosed in > quotes, everything was just separated by a space. This causes tags to > be improperly assigned on the next save. So, I changed the > edit_string_for_tags method to: > > def edit_string_for_tags(tags): > names = [] > for tag in tags: > name = tag.name > if u' ' in name: > names.append('"%s"' % name) > continue > names.append(name) > > return ', '.join(names) > > Now tags are properly formatted in my tags text field, and tags are > properly assigned to objects. This also does not break compatibility > with other DB types for me. Last step will be to replace my > cx_Oracle-4.4.1 driver with the latest 5.0.1, and see if it still > works. > > Hope this helps someone out! > > Cheers, > Brandon > > On Mar 23, 5:40 pm, Brandon Taylor <btaylordes...@gmail.com> wrote: > > > Hi Ian, > > > I'm not that familiar with Oracle, so I have no idea if the problems > > I'm experiencing are related in some way to permissions, etc, but I > > have been reassured by my Oracle person that my user has full > > permissions on my schema. > > > That being said, the TagField() will show up in admin when specifying: > > > from tagging.fields import TagField > > > class MyModel(models.Model): > > tags = TagField() > > > When I create a new record, any tags that I have entered will be saved > > to the tagging tables and associated to the record. However, when I > > update the record, and add tags that aren't already present, or remove > > all of the tags, no changes to the record will occur. All of the tags > > that were there when I created the record are still there, but no new > > tags, and no tags removed. > > > If I take the *exact* same model code, and switch my database to > > SQLite or MySQL, I have no issues. I can only deduce that it's > > something either wrong with my Oracle permissions, or with cx_Oracle > > itself. I have wiped out my tables, re-validated, re-sync'd. Quadruple- > > checked my code. And still the same problem. But yes, at least I can > > add tags. > > > Perplexed, > > Brandon > > > On Mar 23, 4:31 pm, Ian Kelly <ian.g.ke...@gmail.com> wrote: > > > > On Mar 23, 1:52 pm, Brandon Taylor <btaylordes...@gmail.com> wrote: > > > > > Hi Everyone, > > > > > Is anyone having issues with Django Tagging (svn) not updating tags on > > > > an existing model? I'm running cx_Oracle-4.4.1 - thanks to (Ian Kelly) > > > > and Django Trunk. > > > > Hmm. I tried running the same model you posted before with Python 2.6 > > > and cx_Oracle 5.0.1, and I can't see that it makes any difference; it > > > still works for me. Glad you got it (at least partially) working, > > > though. > > > > > I can add tags when a model instance is created, but update/delete is > > > > not working. > > > > Can you be more specific? It seems to be working for me. > > > > Regards, > > > Ian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---