Chris Vickerson
2009-06-01 00:50:07 UTC
I'm cross posting 2 messages that was originally posted on the pylons list.
The reason I'm cross posting it now is I now think this is specific to
formencode. If the problem is that Invalid objects can't be pickled is
there a fix or a work around?
Thanks
[message 1]
Hi - I'm trying to set some session variables inside an exception handler of
FormEncode validation testing. It seems that if I try to save the result of
"error.error_dict" into a session variable all my session variables are
deleted. I experimented with a bunch of different ways to narrow this down.
All I have to do is not try to save error.error_dict and everything works
as expected. My code looks like this:
import formencode
...
class FilesController(BaseController):
def view_by_id(self):
schema = ListForm()
try:
form_result = schema.to_python(dict (request.params))
except formencode.Invalid, error:
session['defaults'] = error.value
session['errors'] = error.error_dict or {} #comment out
this line and it saves ok
session.save()
redirect_to(controller='files', action='list')
class ListForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
file_select =
formencode.validators.Int<http://formencode.validators.int/>(not_empty=True)
I think I've posted enough of the code - it's pretty basic I think. I
searched google/google groups but didn't find any similar problems so I must
be doing something wrong.
Any help is appreciated
[message 2]
I've found a conversation that led me to this open bug:
http://bugs.python.org/issue1692335 I think this is the problem that is not
allowing me to store this
object in session.
The reason I'm cross posting it now is I now think this is specific to
formencode. If the problem is that Invalid objects can't be pickled is
there a fix or a work around?
Thanks
[message 1]
Hi - I'm trying to set some session variables inside an exception handler of
FormEncode validation testing. It seems that if I try to save the result of
"error.error_dict" into a session variable all my session variables are
deleted. I experimented with a bunch of different ways to narrow this down.
All I have to do is not try to save error.error_dict and everything works
as expected. My code looks like this:
import formencode
...
class FilesController(BaseController):
def view_by_id(self):
schema = ListForm()
try:
form_result = schema.to_python(dict (request.params))
except formencode.Invalid, error:
session['defaults'] = error.value
session['errors'] = error.error_dict or {} #comment out
this line and it saves ok
session.save()
redirect_to(controller='files', action='list')
class ListForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
file_select =
formencode.validators.Int<http://formencode.validators.int/>(not_empty=True)
I think I've posted enough of the code - it's pretty basic I think. I
searched google/google groups but didn't find any similar problems so I must
be doing something wrong.
Any help is appreciated
[message 2]
I've found a conversation that led me to this open bug:
http://bugs.python.org/issue1692335 I think this is the problem that is not
allowing me to store this
object in session.
--
Chris Vickerson
***@vickerson.net
Chris Vickerson
***@vickerson.net