Eric Ongerth
unread,May 17, 2012, 6:08:21 AM5/17/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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.