storage for table annotations

Issue #573 resolved
jek created an issue

Would be handy to have storage on Table instances for arbitrary attributes. (For use by extensions and helpers.)

e.g. I have a table annotation 'precious' that interacts with my testing framework. Currently

  t = Table('foo')
  t.precious = True # rather not do this

maybe instead throw this into a general attributes bucket, separate from the dialect kwargs bucket

  t.attributes['precious',)](('testingthing',) = True

or, convenient but fraught:

 t = Table('foo', precious=True)

Comments (7)

  1. jek reporter

    no, this would be for higher level functionality, code operating on abstract tables and collections of tables that needs to stash state. for the example above, i have a type of MetaData that consumes these annotations and implements broad behavioral changes.

  2. Mike Bayer repo owner

    OK, why on Table and not on: mapper, query, session, select(), metadata, etc. ? it seems like an awfully application-specific concept to me (and as such can be handled by either sticking "attributes" on the object yourself, or by using a dictionary of tables->whatever)

  3. jek reporter

    sticking an 'attributes' on myself is fine- as long as it's not going to stomp any internals. how about reserving 'attributes' on core objects for use in the Context style? not that it needs to be added anywhere now, rather that ''if'' the property is someday added to core, that's the interface it will use.

  4. Mike Bayer repo owner
    • assigned issue to

    seems like "attributes" has been getting added to things other than table lately ? (i.e. connection ?) id say this would be Table.attributes, and if constructor-level Table(...., attributes={...}).

  5. Log in to comment