Can't store Invalid object in session
Chris Vickerson <chris-49n0//[email protected]> Sun, 31 May 2009 20:50:07 -0400
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
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.
--
Chris Vickerson
chris-49n0//[email protected]
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
FormEncode-discuss mailing list
FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/formencode-discuss