> Julien Cigar wrote: > > Another quick question, relative to multiple inheritance. > > Is it common to keep a back reference to the parent class within > > the child class ? u mean theclass.__bases__? or what?
> > The idea behind this is that I want to be able to retrieve the > > child from the parent. why u need it? > also, I know that it's not possible under "pure" OO programming, > but I wondered if it's dirty to do it like that ? it is possible, depends on the language and framework. e.g. in smalltalk u can ask which classes are my subclasses. But this is talking about classes, not instances. what u mean child and parent here? if this is about tables, u _can_ have pure child, but that is only incomplete/partial data; full child is all parent attributes plus all child attributes (parent.join(child), that is). And for each full child (complete object), u have one parent-only data and one child-only data... and they are 1:1, so u can get one from another and vice-versa. i think u either have wrong model or something i don't get? if u have different attributes for different Content subtypes, then that means subclasses and eventualy polymorphism. Or u go the single_typee (singletable) way, and put all stuff in Content, and just check for presence/absence of some attributes. > > For example I have something like: > > assign_mapper(session.context, content.Content, t_contents, > > properties=dict(state = > > relation(state.State))) > > > > assign_mapper(session.context, folder.Folder, t_folders, > > inherits=content.Content.mapper, > > properties = dict(data = > > relation(content.Content, secondary=t_nodes, lazy=False))) > > > > assign_mapper(session.context, page.Page, t_pages, > > inherits=content.Content.mapper, > > > > properties=dict(content=relation(content.Content, > > backref='page'))) > > > > container = Folder.get(folder_id) # I get a Folder object > > for data in container.data: > > # Here I have Content objects > > # and I want to be able to see if the Content is a Page or a > > News or ... if data.page: ... > > elif data.news: ... > > ... > > > > the other idea is to add a string like "page" or "news" in the > > Content table (or another table) .. > > what do you think is the best solution ? > > > > Thanks, > > Julien > > > > Julien wrote: > >> OK it was that ! > >> > >> Thanks > >> > >> On Mon, 2007-04-02 at 12:19 -0400, Michael Bayer wrote: > >>> defintiely do not call flush() on "root_folder", call it for > >>> the session overall. thats probably the issue, since its > >>> failing to get the full set of child objects properly in the > >>> flush. > >>> > >>> On Apr 2, 2007, at 10:44 AM, Julien Cigar wrote: > >>>> Hello, > >>>> > >>>> I'm playing a bit with Multiple Table Inheritance (the > >>>> Non-polymorphic way) and I got a problem which I have > >>>> copy/paste on > >>>> http://rafb.net/p/HAhx8p22.html > >>>> > >>>> Here is the basic idea of what I want to do (it's a kind of > >>>> CMS): > >>>> > >>>> - "Content" is the base class for all contents (Pages, News, > >>>> Events, Folder, ...) > >>>> - "Folder" is a "Content" which can contain one or more > >>>> "Content" (Node-like structure) > >>>> > >>>> I suspect that the problem is that I don't have a sequence for > >>>> my primary keys in my subclasses .. ? > >>>> > >>>> Thanks, > >>>> Julien > >>>> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---