Ok, thanks.
This explains what was going on. I did read that when I was first
learning python, but I bet now, I won't forget about it anymore. I
tried working around it, but that wasn't really working as the default
value for the arguments get changed, also using messages = None wasn't
an option as that would clear the message.
I am not using sessions yet, but that will probably be a later add on
and could also solve the problem.
My solution for now is that I added a small class (global object) that
contains the arrays errors and messages. It has addError, addMessage,
getError and getMessage.
I call the set methods whenever I want to add a notice to the user
(error or message) and I call the get method in the render_to_response
statements. The get methods return the arrays and clear them.
def getErrors(self):
retrieve = self.errors
self.errors = []
return retrieve
This allows me to add all errors and messages and then display them
once. This is working for me and does the job for both
httpresponseredirect and render_to_response.
Basic setup:
view(request):
if(request.POST):
#do stuff
setErrors, setMessages
httpresponseredirect
else:
rendertoresponse(... { 'error_list':getErrors,
'message_list':getMessages})
cheers,
Maarten
On Jan 3, 7:38 pm, Peter Rowell <
hedron...@gmail.com> wrote:
> I didn't like my own explanation and did a little more searching.
>
> I just found a better description of this athttp://
requires-thinking.blogspot.com/2007/10/note-to-self-default-pa....