I want to set table, mapper arguments automatically.
The following is the only way I have found to do this.
Is this supported?
Am I wasting my time with Declarative and should rather use the non
declarative if I want this control?

class MyMeta(DeclarativeMeta):

    def __new__(meta, classname, bases, classdict):

        # Copy interesting arguments from base classes
        for base in bases:
            for arg in (a for a in ('__table_args__',
                                    '__tablename__',
                                    '__mapper_args__') if a in
base.__dict__):
                classdict[arg] = base.__dict__[arg]

        return DeclarativeMeta.__new__(meta, classname, bases,
classdict)

Base = declarative_base(bind=engine)

class MyDeclarativeStuff(object):
    # Set some generic stuff up.
    __table_args__ = {'autoload':True}

class Customer(Base, MyDeclarativeStuff):
    __metaclass__ = MyMeta
    __tablename__ = 'customer'

Many Thanks.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to