Thursday, February 9, 2012

Re: Django code patterns

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
break

if has_any:
submit_func(a, b)

def submit(a, b):
a.email = b['email'],
a.is_active = b['is_active']

submit_if_any(
user,
request['POST'],
(
lambda a,b: a.email == b['email'],
lambda a,b: a.is_active == b['is_active'],
),
submit
)

--
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


Real Estate