On Sat, Aug 04, 2007 at 12:09:07PM +0200, Michael Elsdoerfer wrote:
> 
> > def save(self):
> >     if self.id is not None:
> >         old_self = self.__class__.get(id = self.id)
> >     if self.id is None or (old_self.city != self.city) or (
> >       old_self.state != self.state):
> >         self.geocode = self.get_geocode()
> >     super(SiteUser, self).save()
> 
> You can also monitor attribute changes via __setattr__, which will save you
> an additional query. That worked fine for me so far, although I am not 100%
> if there might not be some edge cases that could cause problems.

I can't think of any problems with that sort of approach, excluding the usual
problem of the database changing underneath you.  Didn't think of it, but it's a
good idea.

-Forest
-- 
Forest Bond
http://www.alittletooquiet.net

Attachment: signature.asc
Description: Digital signature

Reply via email to