Yes, the erroneous behavior goes away when this code is commented out.
No, an empty instrumentation manager *does not cause* the error. Note
that I had a sqlalchemy Table object called 'attributes' in my model.
I have changed the code so that I do not import 'attributes' from
sqlalchemy.orm but instead fully-qualify it. Similarly, I have changed
the model code to refer to 'chimera_columns' rather than 'attributes'.
I have also renamed the mapped property 'attributes' as 'columns' as
at my workplace, nobody other than myself refers to database columns
as 'attributes'!
class AttachNotesAsDocstring(interfaces.InstrumentationManager):
pass
sqlalchemy.orm.attributes.instrumentation_finders.insert(0, lambda
cls: AttachNotesAsDocstring)
However, despite all these changes, if I provide an implementation of
instrument_attribute as follows then I get the dreaded
'ColumnProperty' object has no attribute 'strategy' error.
def instrument_attribute(self, class_, key, attr):
if isinstance(attr.property, properties.ColumnProperty):
if hasattr(attr.property.columns[0], 'info'):
attr.__doc__ = attr.property.columns[0].info.get
('notes')
I can live without the docstring fanciness for now but it has been
educational tracking down the various problems.
pjjH
On Apr 3, 3:04 pm, "Michael Bayer" <[email protected]> wrote:
> [email protected] wrote:
>
> > # class AttachNotesAsDocstring(interfaces.InstrumentationManager):
> > # def instrument_attribute(self, class_, key, attr):
> > # if isinstance(attr.property, properties.ColumnProperty):
> > # if hasattr(attr.property.columns[0], 'info'):
> > # attr.__doc__ = attr.property.columns[0].info.get
> > ('notes')
>
> > # attributes.instrumentation_finders.insert(0, lambda cls:
> > AttachNotesAsDocstring)
>
> the erroneous behavior is narrowed down to this, correct ? is anything
> within the method raising an error (try putting pdbs or print statements
> in it)? does having just an empty do-nothing instrumentationmanager cause
> the error ?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---