I don't know if I'm following a wrong pattern in the context of Django. 
Inside my class views I need manage exceptions and I would like to pass the 
response workflow to an external method (my exceptions module). In my call 
I pass my ClassView.request variable to be able to use request context 
processors.
I paste an excerpt, where I do the render_to_response call directly from 
the form_valid method, just to test it.

class ProjectCreateView(FormView):
    """Create view."""
    (...)

    def form_valid(self, form):
        """Form and logic behind project creation."""

        project_file = form.cleaned_data['project_file']
        thumbnail = form.cleaned_data['thumbnail']
        description = form.cleaned_data['description']

        try:
            <something to try>
        except IntegrityError as e:
            data = {'error':{'msg':_('project_overwrite_error')}}
            return 
render_to_response('generic_error.html',data,context_instance=RequestContext(self.request))
        except Exception as e:
            return HttpResponse(e)

    return HttpResponseRedirect(self.group.get_absolute_url())

    (...)


Passing the RequestContext instance causes a DatabaseError, raised when it 
tries to test the user.is_authenticated template context variable.

I've noticed that when used in a basic view method, the resolution of 
user.is_authenticated is called only once, while it's hit twice in the case 
of the generic view. I don't know if it can be the source of the error...

Another strange thing is that it doesn't happen if I debug with a 
breakpoint inside the view dispathc method. Wired!

Here it is the stacktrace: https://gist.github.com/anonymous/6460412

First, I would like to understand why this happens.
Second, how should Itransfer the response flow outside a generic view? It 
works fine until I don't ask for the user variable, so I suppose there 
should be a cleaner way to manage the control tranfer.

Would you help me to solve the issue?
Thanks a lot,
Giovanni

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to