views:

273

answers:

1

I've read the similar question on adding tags to a Django Blog model, where it mentions maintaining tags on the article as a StringList and a separate object to keep a count of these objects, which is good because I'd basically come up with the same idea myself, however I'm struggling to work how how to maintain the count.

I'm overriding the put() method of the main object, but how do I check to see if the tags have changed compared to the object currently stored? Is there any way to cheaply check the existing data without fetching a 2nd copy of the object?

One way to handle it is to store each object in memcache and only fetch the ones it doesn't find in there, but for a busy site, you're still going to be hitting the datastore quite often.

+2  A: 

Check out taggable-mixin. It's a pretty straightforward way to add tags to any AppEngine model class as a mixin.

Adam Crossland
Thanks for the answer Adam, I had a little work to do to get it working under Django, but it really was only a little.I've updated the Tiddlywiki that comes with it with what I had to do to get it working, and mailed it back to you.
Stuart Grimshaw
Stuart! Thanks so much! It's incredibly decent of you to contribute back what you discovered.
Adam Crossland
taggable-mixin has a flaw that it saves a list of all the tagged entities in the Tag model.If you have lots of entities (think of a system like StackOverflow for example) the Tag entity will explode.Its better to save that reference in the taggable entity - each entity has a list of tags.
Eran Kampf