Michael Bayer wrote:
- Declarative mixins can do everything now. You need to use sqlalchemy.util.classproperty in most cases to do it.

Cool, but the spelling is a little cumbersome:

class MyMixin:
    @classproperty
    def type_(cls):
        return Column(String(50))

It'd feel more natural to spell this:

from sqlalchemy.ext.declarative import MixinColumn

class MyMixin:
    type_ = MixinColumn(String(50))

...or...

class MyMixin:
    type_ = Column(String(50),mixin=True)

Of course, this explodes a little in terms of new constructs needed for relationship, deferred, etc.

But, essentially, the above all just needs to be spotted by DeclarativeMeta and indicate "copy" instead of "do nothing", right?

So, how about:

from sqlalchemy.ext.declarative import mixin

class RefTargetMixin(object):
    target_id = mixin(Column('target_id', ForeignKey('target.id')))
    target = mixin(relationship("Target",
            primaryjoin="Target.id==%s.target_id" % cls.__name__
            )

...and so on.

If you're amenable to that, I'll work up a patch set.

I feel bad that I wasn't able to help with the reported bugs given how hard I pushed for mixins, a combination of lack of time but more lack of deep knowledge of the rest of SQLAlchemy was to blame :-(

cheers,

Chris

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en.

Reply via email to