Hi

what exactly is the problem with the if check?
Why is it so bad?

On Thu, Dec 9, 2010 at 4:21 PM, Quetzacotl <quetzaco...@gmail.com> wrote:

> Hello, this is rather python problem, but maybe You can help. What i
> want to do is to return value in another function calling from other
> function.
>
> It doesnt mean i want this:
>
> def Func():
>     return 1
>
> def Func2():
>     return Func()
>
> I want function Func to return 1 directly in Func2 as it is Func2
> returning it.
>
> I have this problem because view function has to return response
> object and my function that adds element to database (comments)
> returns HttpResponseRedirect or context dict with form that has
> errors.
> If it returns redirect then i want view function to return it, if it
> return context then i dont want to return it but rather give it to
> render_to_response.
>
> It comes to this:
>
> def Add():
>     #form valid, add to db
>     return { 'redirect': HttpResponseRedirect('url'), }
>
>     #form not valid
>     return { 'form': form, 'redirect': 0, }
>
> def View(request):
>     add = Add()
>     if add['redirect']!=0:
>          return add['redirect']
>
>     return render_to_response(template,add)
>
> Thing i dont want here is if statement checking if there is redirect,
> so i want within function Add return HttpResponseRedirect as it is
> View function.
>
> I dont know if this is possible.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
eng. Ilian Iliev
Web Software Developer

Mobile: +359 88 66 08 400
Website: ilian.i-n-i.org

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

Reply via email to