Dan wrote:
> There is a functionality which I am interested in and I wonder what is
> the cleanest and most foward compatible way of doing things.
> 
> I want models to sprout a suggest() method which would work like
> save() but keep the data in some structure elsewhere that do not
> modify the original data. Any regular call to that object would work
> as if it wasn't modified. I also want a accept() method that would
> commit the changes (and obviously a reject() method to discard them
> and some way to explore the suggested changes).
> 
> I am not interested in history at all.
> 
> How would you go about implementing those functionalities?

First guess, curious if others think its good idea.

Create model with one2one nullable field "suggestion" and Boolean field 
"is_suggestion".
If suggestion is Null then there is no suggestion.
If suggestion is not Null it is id of suggested data.

The idea is to avoid maintaining two duplicate schemas.


Proly change the default Manager to only show is_suggestion == False rows.


def suggest(self, obj):
     """obj is original obj self is suggestion for""
     self.is_suggestion = True
     self.suggestion = obj
     self.save()

def accept(self):
     "accept this suggestion"
     assert self.is_suggestion
     # need more logic if model has foriegn relationships
     self.suggestion.delete()
     self.suggestion = None
     self.is_suggestion = False

def reject(self):
     assert self.is_suggestion
     # not sure how to delete relation
     # self.suggestion.suggestion = None ???
     self.delete()


-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___________________________________________________________________________
You've got fun!  Check out Austin360.com for all the entertainment
info you need to live it up in the big city!

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

Reply via email to