Hi All,

I have a mixin defined like this:

def add_exclude_constraint(mapper, class_):
    table = class_.__table__
    elements = [('period', '&&')]
    for col in table.primary_key.columns:
        if col.name!='period':
            elements.append((col, '='))
    table.append_constraint(ExcludeConstraint(*elements))

class Temporal(object):

    @declared_attr
    def __table_args__(cls):
        listen(cls, 'instrument_class', add_exclude_constraint)
        return (
        CheckConstraint("period != 'empty'::tsrange"),
        )

    period = Column(DateTimeRange(), nullable=False, primary_key=True)

That listen call is the source of the dirty feeling...

What's the "right" way to do this?

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
            - http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to