Hello,
I am getting an error message that has got me a bit stumped. If you
have any ideas, I would be very clad of any help. The error is:
--------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.5/site-packages/django/core/servers/
basehttp.py", line 278, in run
self.result = application(self.environ, self.start_response)
File "/usr/local/lib/python2.5/site-packages/django/core/servers/
basehttp.py", line 635, in __call__
return self.application(environ, start_response)
File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
wsgi.py", line 243, in __call__
response = middleware_method(request, response)
File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/
middleware.py", line 35, in process_response
request.session.save()
File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/
backends/db.py", line 53, in save
session_data =
self.encode(self._get_session(no_load=must_create)),
File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/
backends/base.py", line 88, in encode
pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL)
PicklingError: Can't pickle <class
'django.forms.formsets.AuthorWithIdFormFormSet'>: attribute lookup
django.forms.formsets.AuthorWithIdFormFormSet failed
----------------------------------------
I have just updated to the latest svn version ten minutes ago, and I
still get the same error.
The referenced form is for showing authors of packages. It is below;
I apologize if the formatting is off. The only twist that I see is
that I need to have a custom clean() so I make the formset with
formset_factory(AuthorWithIdForm, extra=2, formset=BaseAuthorFormSet).
......................................................................
class AuthorWithIdForm(forms.Form):
author_id=forms.CharField(required=False,widget=HiddenInput)
display_name=forms.CharField(max_length=60,required=False,widget=widgets.AuthorWidget,help_text="Author's
name")
email=forms.EmailField(max_length=72,min_length=1,required=False,widget=widgets.EmailWidget,help_text="Email
(not shown publicly)")
active=forms.BooleanField(required=False,help_text="Active?")
# The author id is encrypted as some protection against people
# messing with my mind.
def encrypt_id(self,x):
return encrypter().asciiEncrypt(x)
def clean_author_id(self):
x=self.cleaned_data.get('author_id',None)
try:
if x is None:
return u''
else:
unencodedId=encrypter().asciiDecrypt(x)
unencodedId=unencodedId.rstrip()
return unencodedId
except:
raise forms.ValidationError(u'The author id field is
corrupted.')
# This allows me to add a custom clean() method to the formset made of
# AuthorWithIdForm's. The clean() method checks that there is at
least
# one author with a display name and of the authors at least one has a
# email.
class BaseAuthorFormSet(BaseFormSet):
def clean(self):
super(BaseAuthorFormSet,self).clean()
cd=[]
try:
if self.cleaned_data:
for dct in self.cleaned_data:
if ('display_name' in dct.keys()
and dct['display_name']
and 'email' in dct.keys()
and dct['email']
and fields.email_re.search(dct['email'])):
cd.append(dct)
if cd:
return cd
except:
pass
raise forms.ValidationError, u'You must name at least one
author, by giving the display name, and at least one of your authors
must have an email.'
.........................................................
If anyone has a hint, or has run across a similar circumstance, I
would be most grateful. No doubt I'm doing something dopey, but I
can't see it.
Thanks,
Jim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---