Hi again,

I'm messing around with my Model and my views and putting a 'unittest'
jig around what I'm building. Certainly, I don't want to test at the
view layer (passing in HttpRequests and getting back HttpResponses), so
I find that I'm writing a "controller-like" layer between the view and
the model.

So, the view may be "saveUser", but it actually delegates to the
controller for something like "attemptSaveUser()" that takes proper
parameters (not POST variables) and throws proper exceptions on error.
The view just translates from POST[], calls the controller, handles the
exceptions and calls the appropriate template as a response.

The unittesting framework only deals with the controller layer.

I could have moved all this down into the model layer, but on initial
create operations there is no model object to work with. This means I
would have to use a static method on the class (not exactly trivial in
python) and given the magic that occurs on the model objects I wonder
if static methods would work and not break things.

What are your thoughts on my approach to testing here (creating the
controller layer) or my concerns about moving these methods into the
model?

I think ideally these methods belong in the model, but I'm worried that
it's a lot of work to make it work elegantly. I suppose another
alternative is to just put functions in the model, but then you lose
your ability for inheritance (as you do in the model anyway).

Thoughts?
-Zeb

Reply via email to