[Grok-dev] adding objects to context from __init__
Raphael Ritz
r.ritz at biologie.hu-berlin.de
Tue Oct 7 06:49:32 EDT 2008
John de la Garza wrote:
[..]
> I mean the variable text gets persisted between restarts of the
> server, but if we added a list by doing this:
>
> class Sample(grok.Application, grok.Container):
> list = []
>
comment from a lurker:
Browsing through the tutorial I've seen that the important
topic of persisting mutable objects is covered (good!) by
using the '_p_changed' magic but I just want to ask the
question whether people consider this to be best practice?
At least I switched to using the persistent types that the
ZODB provides for exactly that reason (PersistentList and
PersistentMapping). Maybe this could be mentioned somewhere
in the tutorial? (unless it is and I just messed it)
Raphael
>
> it would be reset to empty every time we restarted the server
>
>
> I'd expect text='default text' to have the same resetting as list=[]
>
>
> What am I over looking?
More information about the Grok-dev
mailing list