[sqlalchemy] Re: Tagging example
I'm a SA newbie, so bare with me :) This is the SQL query for a tag cloud, returning each tag_name and it's weight (the count of page tagged with this tag). SELECT tag_name, COUNT(page_id) AS quantity FROM pages_tags JOIN tags USING (tag_id) GROUP BY tags.tag_id ORDER BY quantity DESC; What's the SA equivalent? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Tagging example
i have some notes on how to create instances that are unique to some identity: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/UniqueObject as far as it being a list of normal strings, thats a feature we havent implemented as of yet. hibernate does it, you can make collections of ints or strings instead of objects. its not as much a burning need in python since you can use object tricks to create the same effect...but i would like to look into that feature someday (tho it would probably be just my institutionalizing a particular class- based trick). On Jan 26, 2007, at 6:37 PM, Damjan wrote: I've been folowing this document http://www.thesamet.com/blog/2006/11/17/tutorial-how-to-implement- tagging-with-turbogears-and-sqlalchemy/ and created this model http://rafb.net/p/M4pfAD74.html (criticism welcomed). Now, creating pages and then adding tags to them like so: p1.tags.append(Tag('test')) p2.tags.append(Tag('test')) will actually create two 'test' tags in the database... also does p1.tags be a list of Tag instances? Can it be a list of normal strings? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Tagging example
Well in this case, the Tag class is really unnecesseary --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Tagging example
Damjan schrieb: Now, creating pages and then adding tags to them like so: p1.tags.append(Tag('test')) p2.tags.append(Tag('test')) will actually create two 'test' tags in the database... Have a look at my tagging tutorial at http://paddyland.serveblog.net/article/16#updating-tags Although it uses SQLObject, the pattern used in the 'update_tags' method (http://paddyland.serveblog.net/article/16#updating-tags) can be applied to SQLAlchemy as well. also does p1.tags be a list of Tag instances? Can it be a list of normal strings? taglist = [str(tag.name) for tag in p1.tags] HTH, Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---