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.


On Thursday, May 17, 2012 3:08:21 AM UTC-7, Eric Ongerth wrote:
>
> (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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/tnJBFf0OOtEJ.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to