To make my life easier, I developed a custom __setattr__ function
which throws an error on any attempt to set an unknown property name.
Would it be useful to include this behavior as an option in SQLElixir?
If so, I can make the code available.
Barry
Btw: the code you speak of is the one at:
http://www.sqlalchemy.org/trac/attachment/ticket/547/code.txt
right?
--
Gaëtan de Menten
http://openhex.org
That's right. Another concern is performance, due to the overhead of
additional checking. For that reason, most people would only want to
do this in development code, not production.
There is a pretty easy workaround for transient attributes - you can
use Python's property feature, where you define setter and getter
methods for the property -- as written, the error checking function
detects and allows these to be set.
I see this function mainly as an aid in porting from SQLObject; once
someone is writing new code on SQLAlchemy, they will most likely catch
attribute naming errors in their normal code/debug cycle.
>http://www.sqlalchemy.org/trac/attachment/ticket/547/code.txt
>right?
Yes.
Barry
On Apr 23, 12:58 pm, "Gaetan de Menten" <gdemen...@gmail.com> wrote:
> I'm not sure on this one. What I'm sure of is that we can't have this
> on by default. The problem is that, from what I understand, such a
> code will trigger errors for simply having instance attributes which
> are not persisted. I'd either include this as an option, or make an
> example/FAQ out of it. My personal vote is for the second option.
>
> Btw: the code you speak of is the one at:http://www.sqlalchemy.org/trac/attachment/ticket/547/code.txt
> right?
>