[Grok-dev] Modeling a class that extend from list() with megrok.rdb
white.lists at gmail.com
Mon Oct 25 18:02:01 EDT 2010
I am trying to migrate my application from ZopeDB to MySql. I am using
I have a class which inherits from list() and has a few extra methods.
That class acts as a container of other classes and is used (as an
attribute) in other classes as well:
self.field1 = “field1”
self.field2 = “field2”
if isinstance(myEntry, MyEntry):
def getByField1(self, field1):
for element in self:
if element.field1 == field1:
[ ... more useful methods ...]
self.container1 = MyContainer()
self.container2 = MyContainer()
self.anotherField = “hello world”
I don't really know how to model this with megrok.rdb. I kind of see
clearly (although I may be totally wrong) that MyEntry and MyClass
should extend from rdb.Model and each of them should be stored in a
table, but I don't really know what to do with “MyContainer”. I'd like
to keep it inheriting from list, but I don't know how to model that.
It really only needs to be an association between [id, id_of_my_entry]
(relationship 1:N). In MyClass, each of the containers would get an id
and then, if I want to get the “MyEntries” that are in container1, I
just need to get the MyEntries who are linked to that id.
… but I have no idea about how to implement that... Any hint I could
get would be deeply appreciated.
Thank you in advance!
More information about the Grok-dev