With a mapped class instance, if I try and set an unmapped attribute, 
Sqlalchemy simply adds this new attribute (locally) to the object, and 
subsequent 'get' operations return the assigned value.

Base = declarative_base()


class MyClass(Base):

__tablename__ = 'some_table'

id = Column(Integer, primary_key=True)


           ...

           obj = MyClass()
           ## This correctly raises 'AttributeError'
           print obj.unmapped_attribute

           ## This does not fail!
           obj.unmapped_attribute = 0
           ## Also does not fail anymore, prints "0"
           print obj.unmapped_attribute 
 
I'd like to have an 'AttributeError thrown whenever I try and set a bad 
property, similar to the getattr() behavior. Is this possible? Maybe I'm 
doing something wrong?

(Using SqlAlchemy 0.7.9, Python 2.7)

-- 
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/-/rAV73iowHsUJ.
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.

Reply via email to