On Thu, Aug 21, 2008 at 2:43 PM, Victor Lin <[EMAIL PROTECTED]> wrote:
>
> I'd like to inherits from different multi-entities like this:
>
> class FormulaOperand(Operand, TraceLink):
>    using_options(inheritance='multi')
>    using_options(tablename='formula_operand')
>
>    def getValue(self):
>        pass
>
>    def __repr__(self):
>        return '<FormulaOperand reference formula %s>' % self.formula
>
> But...oops!
>
> Exception: FormulaOperand entity inherits from several entities, and
> this is not supported.
>
> Here comes the problem. It seems that Elixir does not support inherits
> in that way?
> So I have to choice one to inherit, and another to be has-a
> relationship?
>
> How about this:
>
> class FormulaOperand(Operand):
>    using_options(inheritance='multi')
>    using_options(tablename='formula_operand')

By the way, you can write this as:
     using_options(inheritance='multi', tablename='formula_operand')

>
>    link = ManyToOne(TraceLink, required=True)
>
>    def getValue(self):
>        pass
>
>    def __repr__(self):
>        return '<FormulaOperand reference formula %s>' % self.formula
>
> So I have to set link manually. Is there any better way to do so?

Not that I know of. SQLAlchemy doesn't support having a mapped class
(or rather mapper) inherit from several mappers. You can suggest the
feature on SQLAlchemy if you want. Once that is done, adding support
for it in Elixir shouldn't be too hard I think.

Until then, you could define a specific __init__ method for
FormulaOperand which would create a new link automatically, so it's
not that bad.

def __init__(self, ...):
    self.link = TraceLink()
    ...


-- 
Gaƫtan de Menten
http://openhex.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to