开发者

Some kind of event functionality in Django?

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 scenar开发者_如何学Goio 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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜