One thing I seem to remember is that changes made in __setstate__ do not mark
the object as dirty. This is because after being loaded an object is up-to-date
by definition.
I suggest going with zope.generations.
Stefan
On 19.06.2012, at 23:42, Malthe Borch wrote:
> On 19 June 2012 23:38, Cl
On 19 June 2012 23:38, Claudiu Saftoiu wrote:
> Is there any hook to call *after* the instance attributes get set/loaded
> from the database?
True. I guess you'll have to go with Marius' suggestion – ``__setstate__``.
\malthe
___
For more information a
>
> You'll need to override ``__new__``. That's your hook. It's called
> when the database instantiates the object. Note that this is always
> true for Python. The ``__new__`` method is always called before an
> object is instantiated.
>
Actually, this doesn't seem to be what I want. ``__new__`` i
On Tue, Jun 19, 2012 at 10:15:03PM +0200, Vincent Pelletier wrote:
> Le mardi 19 juin 2012 19:54:21, Claudiu Saftoiu a écrit :
> > def calc_it(self, b):
> > if not hasattr(self, 'b_cache'): self.b_cache =
> > PersistentDict()
>
> If you were to use this, you would probably pref
On Tue, Jun 19, 2012 at 2:29 PM, Malthe Borch wrote:
> On 19 June 2012 19:54, Claudiu Saftoiu wrote:
> > That is, a function called whenever the object is loaded, that does all
> the
> > necessary backwards-compatibility
> > work right there. It separates the backwards-compat code cleanly, and
>
Le mardi 19 juin 2012 20:50:55, Marius Gedminas a écrit :
> Yes, you can override __setstate__:
[...]
> It's also best to avoid write-on-read semantics, because those tend to
> cause database growth and increase the chances of getting ConflictErrors.
This is also a problem with __setstate__, and I
Le mardi 19 juin 2012 19:54:21, Claudiu Saftoiu a écrit :
> def calc_it(self, b):
> if not hasattr(self, 'b_cache'): self.b_cache =
> PersistentDict()
If you were to use this, you would probably prefer to do
try:
self.b_cache
except AttributeError:
self.
On Tue, Jun 19, 2012 at 01:54:21PM -0400, Claudiu Saftoiu wrote:
> Ideally I could do something like this:
>
> class Foo(Persistent):
> def __init__(self, a):
> self.a = a
> self.b_cache = PersistentDict()
>
> def __just_loaded__(self):
> if
On 19 June 2012 19:54, Claudiu Saftoiu wrote:
> That is, a function called whenever the object is loaded, that does all the
> necessary backwards-compatibility
> work right there. It separates the backwards-compat code cleanly, and also
> only updates the objects
> as-needed... though still a mino
Hello all,
It is often the case that I have a Persistent object that evolves over
time. E.g., it might start off as this:
class Foo(Persistent):
def __init__(self, a):
self.a = a
def calc_it(self, b):
return expensive_function(a, b)
I'll then have a fe
10 matches
Mail list logo