[storm] self-referencing table

Gustavo Niemeyer gustavo at niemeyer.net
Fri Feb 8 17:28:45 GMT 2008


Hey Wilson,

> Is it possible to use storm to handle self-referencing tables ?
> I have made a trial with the following code:
> 
> class Category(object):
>     __storm_table__ = "category"
>     id = Int(name="id_category", primary=True)
>     name = Unicode()
>     id_parent = Int()
>     parent = Reference(id_parent, Category.id)
> 
>     def __init__(self, name):
>         self.name = name
(...)
> Is there any way to make this work?

Yep. Try this:

    parent = Reference(id_parent, id)

-- 
Gustavo Niemeyer
http://niemeyer.net



More information about the storm mailing list