Re: Django code patterns
> Why are you only saving if you've made a change? (Just make sure you
> aren't optimizing prematurely.)
I have a lot of signals going round, so I wan't to keep saves to a
minimum. But
nothing bad would happen if I always saved in this case. Thus the code
would
look:
resource.user.email = request.POST['email']
resource.user.is_active = request.POST['is_active']
resource.user.save()
But I meet the pattern I mentioned a lot in different shapes and
sizes, allow me to
try and describe it in words:
1) Check for a condition, and change a value if true.
2) Goto 1) several times.
3) If any of the conditions is met, perform an action.
I'm looking for a better pattern than the very procedural one Im used
to using.
> *http://code.activestate.com/pypm/django-dirtyfields/
That looks very interesting, thankyou for that.
--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home