Hey Mike,

I can expand my example. I have an orm mapped attribute like this

class Obj(Base):
    _evaluator = Column(String)

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self._eval_func = eval(self._evaluator)

    @orm.reconstructor
    def init_on_load(self):
        self._eval_func = eval(self._evaluator)

    @property
    def evaluator(self):
         return self._eval_func

    @evaluator.setter
    def set_evaluator(ev):
        self._evaluator = ev
        self._eval_func = eval(self._evaluator)

You can see that I have to explicitly set self._eval_func in three 
different places, when really I just want to set it every time 
self._evaluator is set.

It looks to me like the orm events are just a different way of placing the 
different settings of this class attribute

Also, I would like to not call eval in the getter of the property for the 
sake of performance (I know that would simplify the issue).

Is there a way to intercept the setting of self._evaluator for all cases?

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to