On 3/31/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
>
> On Mar 31, 2006, at 1:30 PM, Alan Bailey wrote:

> > IsModified()
>
> This could be useful, but it's probably not worth doing since Django
> would have to keep two copies of all your data in memory to figure
> this out.  Doubling the memory footprint of Django isn't on my wish-
> list :)

Some time ago (about 3 yrs now and a bit at the 2005 PyCon)) when I
was working on an ORM (SQLORB), the way I handled this was to keep a
__uncommitted dict. There was a __setattr__ hook (and later
properties) so that when you changed an attribute, it would be stored
in __uncommitted, and also the object would be registered with the
transaction manager (i.e. appended to a list).  Then when you called
commit() on the transaction manager, it would iterate over the list,
and issue UPDATE for each object's __uncommitted data and then finally
call commit() on the database connection. When doing getattr, it would
check __uncommitted first, and then fall back to using the original
property (if any) or __dict__.

In that scenario, isModified() reduces to bool(obj.__uncommited).
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to