'_Label' object has no attribute 'nullable'

7 views
Skip to first unread message

Eric Ongerth

unread,
May 17, 2012, 6:08:21 AM5/17/12
to sqlal...@googlegroups.com
(using sqlalchemy 0.8.0b1)

Using the new 8.0 inspection mechanism, I can perform the following on one of my model classes in an ipython or bpython shell and obtain a boolean result:

>>> [... bunch of imports to load up my model classes ...]
>>> inspect(SomeClassOfMine).attr['foo'].columns[0].nullable
True

But it seems I can only do this successfully in a shell.  When the same line of code is encountered at runtime, I get the following error:
AttributeError: '_Label' object has no attribute 'nullable'

Further info: this is in a shell initiated with respect to my Pyramid project by invoking "pshell -p bpython development.ini".

What I'm actually trying to do: got some mako templates generating HTML forms from my model classes, and just want to have non-nullable fields generate the "required" keyword in my input elements.  Perhaps there is another better way to reach the 'nullable' property of a column?

Fishing for an easy answer here, but if none is forthcoming I'll knuckle down and build a testcase.

Eric Ongerth

unread,
May 17, 2012, 6:28:38 AM5/17/12
to sqlal...@googlegroups.com
Answered my own question here.

My code was actually working fine at runtime, it's just that one of the objects it encountered which I had thought was a simple column was actually a ColumnProperty which of course had no 'nullable' attribute.
Reply all
Reply to author
Forward
0 new messages