Thanks Mike, I oversimplified a little bit (the factory function takes more
arguments than self.stops, not part of the Planning class), but if i create
the factory with partial I think it will work.
On Monday, November 16, 2020 at 6:16:24 PM UTC+1 Mike Bayer wrote:
> I would use a memoized
I would use a memoized descriptor for that and have it evaluate when called.
Amazingly, i can't find public examples of Python memoize decorators that
aren't overwrought.we use one that is completely efficient and simple:
class memoized_property(object):
"""A read-only @property that is
Hi Mike,
What if during reconstruction you need a one-to-many attribute, like:
class Planning(SqlaBase):
stops = relationship("Stop", back_populates="planning", lazy="joined")
matrix_factory = Matrix
def __init__(self, **kwargs):
super().__init__(**kwargs)
On Aug 6, 2017 1:33 PM, "Shane Carey" wrote:
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 =
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):
On Fri, Aug 4, 2017 at 6:07 PM, Shane Carey wrote:
> I am trying to remove duplicate code in this scenario described here
>
> http://docs.sqlalchemy.org/en/latest/orm/constructors.html
>
> class Obj(Base):
> def __init__(self, **kwargs):
>
I am trying to remove duplicate code in this scenario described here
http://docs.sqlalchemy.org/en/latest/orm/constructors.html
class Obj(Base):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.extra = # ... some complicated construction based off of a
kwarg