> > I am using SQLAlchemy 0.5rc4. > Is there a way to test if the values of an object are valid > for > commiting? I tried something like: > try: > session.commit() > except: > notify the user > > But the problem is, that if the commit fails and I change the non > valid value to a valid one the session will still not commit. why? if u try again and all is ok...
> One other thing I'd like to know: > Is it possible to ask a mapped object information about the mapped > values like: > - what data type is expected (int, str ...) > - what is the maximal length > - is it nullable > these things... (SQL-schema as such) are there, but may or may not be relevant at user-level. unless it is low-level enough. u need to traverse: for x in instance_mapper(obj).iterate_properties, get each x.prop's column (depending on property type, see orm.properties.py), and see what's in there. usualy "validity" is application-concept, so it's up to you what it means. u may use hook at a mapperExtension or sessionExtension, or call some .validate()-like method of yours before saving. see formEncode package for validation-only framework. ciao svil --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. 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 -~----------~----~----~----~------~----~------~--~---