tags:

views:

44

answers:

2

I have a view my Django application which when invoked calls my backend. My backend logic sometimes reaches a point when it needs user input to continue. When this happens, I pickle dump my backend data into the session so that i can resume it later on.

Currently i have defined the scenario when user input is required as a custom exception which i raise. This exception bubbles up all the way to the view where I trap it and do the needful. This works but it isn't really an exception. Is there some kind of event functionality in Django that I could use? Is there a better way to accomplish this?

A: 

Personnaly, I use the exception mechanism for this kind of stuff and I don't really see why I shouldn't

Ghislain Leveque
I thought so too. Then I came across Django signals but I don't know whether it is intended for this. I guess I'll stick to using exceptions for this for now.
Mridang Agarwalla
Signals are not intended for this. There are intended to be "warned" when something happens so that you can react. For example, you could want to have a hook creating the UserProfile when a new User is created. Then you would use signals.
Ghislain Leveque
A: 

I'd say there are two ways: You assume that data should be present and if they are not, custom exception should be raised as mentioned.

However, if it's part of expected workflow and it may just be present in a state, I'd handle it accordingly, i.e. by checking results from view calls.

(And I'd say that continuations from Seaside are best solution for this, as far as I understand them)

Definitely, signals are not for this; they are designed to "hook" on specific events, which is not what You want.

Almad