[Grok-dev] Modeling a class that extend from list() with megrok.rdb
Hector Blanco
white.lists at gmail.com
Wed Oct 27 16:47:40 EDT 2010
Oh, I see.
It seems it works a little bit like the selectors in JQuery, correct?
(which kind of "wrap" the element itself in JQuery objects).
Thanks for the hint. I still haven't reached that part. I am still
trying to migrate MyContainer thing... But I'll keep this in mind.
> You can have whatever class you like in python and keep the items in a list
> inside that data structure, but if they are stored in MySQL, you are getting
> them and putting them with sql.
>
> class WhateverContainer(rdb.Model):
> .
> .
> .
> def get_items(self, container_id):
> return rdb.Session().query(self.items).filter(self.id ==
> container_id).first().items
>
> double check the results of first(), I can't remember if you get the object
> or a list with one object. In which case it's be:
>
> ...).first()[0].items
>
> class MyClass(object)
>
> def __init__(self):
> self._list = WhateverContainer().get_items(<container_id>)
>
> or something to that effect.
More information about the Grok-dev
mailing list