Django code patterns

2012-02-09 Thread Rune Kaagaard
Dear django-users I keep doing patterns like: has_changed = False if resource.user.email != request.POST['email']: resource.user.email = request.POST['email'] has_changed = True if resource.user.is_active != request.POST['is_active']: re

Re: Django code patterns

2012-02-09 Thread Rune Kaagaard
> 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 = requ

Re: Django code patterns

2012-02-09 Thread Rune Kaagaard
Maybe something like the following untested code: def submit_if_any(a, b, conditions, submit_func): has_any = False for condition in conditions: if condition(a, b): has_any = True

Port of Django Template Language to PHP

2011-08-20 Thread Rune Kaagaard
Thanks for your time! Rune Kaagaard -- 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+unsubscr...@googlegroups.c

Re: Port of Django Template Language to PHP

2011-08-21 Thread Rune Kaagaard
@Yaşar: Thanks a lot, would love to see the post if you really do write it! @Kenneth+@Masklinn: You are right, there are a lot of template languages already, but this particular wheel is - unlike twig - not a compiled language but implemented in pure PHP as an Iterator, allowing it to blend in as

Re: Port of Django Template Language to PHP

2011-09-16 Thread Rune Kaagaard
@Kenneth Heh, no understood what you meant, but guess I could have separated my answer better. Sorry about that! cheers Rune Kaagaard On Aug 22, 9:10 am, kenneth gonsalves wrote: > On Sun, 2011-08-21 at 16:22 +0200, Rune Kaagaard wrote: > > @Kenneth+@Masklinn: You are right, there are