[storm] Beginner question: adding referenced objects to store
Neil de Carteret
storm-list at n3dst4.com
Tue Jun 30 19:43:47 BST 2009
I've come unstuck while trying to learn the basics of Storm by writing
a basic wiki:
I have a simple many-to-many relationship, between page and tags. I
have Page class, a Tag class, and a PageTag class, and three matching
tables. When I set the tags used by a page, I'd like to able to say:
>>> page.tags = [Tag(u"mytag"), Tag(u"othertag"), Tag(u"thirdtag")]
where "page" is an instance of my Page storm class, and Tag is the
storm class for tags (with an appropriate __init__.)
The problem I'm having is that the tag objects are not getting
persisted when I "store.commit()".
If I explicitly say:
>>> mytag = Tag(u"mytag")
>>> store.add(mytag)
>>> ...etc
Then the tags are saved. Which is a start, but still nothing goes into
the linker table. And because I don't have any actual PageTag
instances to play with, I can't store.add() them by hand.
Am I missing the point here? What would be the right way to do this in Storm?
You can see a boiled-down test case for what I'm trying to do here:
http://paste.pocoo.org/show/125858/
Thanks in advance,
Neil de Carteret
More information about the storm
mailing list