[storm] How to define two Storm tables that reference each other
Brad Allen
ballen at zeomega.com
Mon Feb 1 16:22:27 GMT 2010
On Mon, Feb 1, 2010 at 9:09 AM, Fernando Correa Neto <fcdoth at gmail.com> wrote:
> Hello,
>
> I think that quoting the table fields would solve the problem.
Right; Alec, you will also need to inherit from the Storm base class
tosupport the quoted references. It should look like this:
class Article(Storm):
"""
This is a Storm table: articles
"""
__storm_table__ = "articles"
id_ = Int(primary=True)
url_id = Unicode()
title = Unicode()
tags = Unicode()
author = Unicode()
timestamp = Unicode()
content = Unicode()
comments = ReferenceSet(id_, 'Comment.article_id')
comment_count = len(comments)
ip = Unicode()
active = Int()
class Comment(Storm):
"""
This is a Storm table: articles
"""
__storm_table__ = "comments"
id_ = Int(primary=True)
author = Unicode()
article_id = Int()
article = Reference(article_id, 'Article.id_')
thread_id = Int()
timestamp = Unicode()
email = Unicode()
website = Unicode()
text = Unicode()
More information about the storm
mailing list