[Zope-dev] ZClass inheriting from Python Class

Martijn Faassen M.Faassen@vet.uu.nl
Thu, 22 Jul 1999 16:57:27 +0200


Michel Pelletier wrote:

>  From: Martijn Faassen [mailto:faassen@vet.uu.nl]
> > So if I use a list attribute in my class to which I append I
> > do need to,
> > right?
> >

> Not necesarily, you can do this:
> 
> list = self.list
> 
> list.append(blah)
> ...
> self.list = list
> 
> The final assignment will be caught by the persistence machinery and
> your appends will be saved with it.  If you look at the Catalog code,
> you'll see I did this all over the place and n'er once used commit().

Ah, useful trick -- code might be faster too due to avoiding variable
lookups. Though in some cases commit() may be cleaner. I'll see what
works best for me.

Thanks!

Martijn