On 20 avr, 16:03, Gaetan de Menten <[email protected]> wrote:
> On Mon, Apr 20, 2009 at 15:42, KLEIN Stéphane <[email protected]> 
> wrote:
> > what do you think about "abstract" entity option like Abstract base
> > classes feature in Django ORM (http://docs.djangoproject.com/en/dev/
> > topics/db/models/#id6) ?
>
> > I need this feature, if you think it is useful feature, I going to
> > work on.
>
> You can already have a similar behavior by using a custom base 
> class:http://elixir.ematia.de/trac/browser/elixir/trunk/tests/test_customba...
>
> The only shortcoming I know of for this approach is that you can't
> have an abstract entity which inherits from a non-abstract one, but I
> don't think this is very useful in practice.

This is a working dirty example (http://pypaste.com/
4ApPiBlwAHHcNJ6JNQPOSw) :

::

    from elixir import *

    metadata.bind = 'sqlite:///test.db'

    class BaseA(object):
        field_a = Field(Unicode())

    class AbstractA(BaseA):
        __metaclass__ = EntityMeta

    class AbstractB(BaseA):
        __metaclass__ = EntityMeta
        field_b = Field(Unicode())

    class C(AbstractB):
        field_c = Field(Unicode())

    class D(AbstractB):
        field_d = Field(Unicode())

    class E(AbstractA):
        field_e = Field(Unicode())

    if __name__ == '__main__':
        setup_all()
        create_all()

This is what I would like (http://pypaste.com/
2f7cBSGCSiIsku6ZDDM0vU) :

::

    from elixir import *

    metadata.bind = 'sqlite:///test.db'

    class AbstractA(Entity):
        using_options(abstract = True)

        field_a = Field(Unicode())

    class AbstractB(Entity):
        using_options(abstract = True)

        field_b = Field(Unicode())

    class C(AbstractB):
        field_c = Field(Unicode())

    class D(AbstractB):
        field_d = Field(Unicode())

    class E(AbstractA):
        field_e = Field(Unicode())

    if __name__ == '__main__':
        setup_all()
        create_all()

In my personal stuff, I've many generic model with multi inheritance.
This is why I need this feature.

What do you think about this 'using_options(abstract = True)'
feature ?

Regards,
Stephane
--~--~---------~--~----~------------~-------~--~----~
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