8 Feb 2008 04:10
self-referencing table
Hi all,
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
But I have got a NameError, because Category was already not defined.
I also have tried this code:
class Category(object):
__storm_table__ = "category"
id = Int(name="id_category", primary=True)
name = Unicode()
id_parent = Int()
parent = None
def __init__(self, name):
self.name = name
self.parent = Reference(self.id_parent, Category.id)
and it does not worked too.
(Continue reading)
RSS Feed