-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pickling error when auto_append = False #44
Labels
Comments
obscode
changed the title
Pickling error when auto_append = True
Pickling error when auto_append = False
Feb 10, 2016
+1 i've found the same error this week. Any ideas? |
Same error here with the last version in Plone5.2/python3. |
That problem haunted me too today.
This should get fixed in this PR: #106 |
Should be fixed with: #106 |
It happened to me with DataGridField and LinkFieldWidget. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using this awesome widget in a form. I want to disable the auto_append feature. I followed the instructions in the README file and used the form's updateWidgets() function to set the widget's auto_append = False.
If I fill out the data with a single row (i.e., DO NOT add or subtract), and I get an error:
[...]
PicklingError: Can't pickle <class 'z3c.form.interfaces.NO_VALUE'>: it's not the same object as z3c.form.interfaces.NO_VALUE
This occurs because when rendering the HTML for the widget, two rows are made: the input row and the template for the next added row (the 'TT' row). But the hidden count variable is set to 2 instead of 1 and this causes (I'm guessing) the NO_VALUE problem. Interestingly, if I add a row, then subtract it, the count goes down to 1 and the form submits correctly. I guess the JS logic fixes the problem in this case.
Debugging a bit, it seems that the function datagridfield.DataGridField.updateWidgets() will always add the "AA" and "TT" widgets because this is run before auto_append can be set to False (it is run as part of the super class' updateWidgets()). So there are always at least 3 widgets. But in the page template for the widget (datagridfield_input.pt) there is a conditional that will prevent the 'AA' widget from rendering if auto_append is False (which it is by the time the page template is rendered). So there's a timing with when self.auto_append is accessed giving inconsistent values.
I fixed the issue for this specific case by simply hacking datagridfield.py and hard-coding the default auto_append=False so everything is consistent from the get-go. But that's not a good solution. Not sure what is.
The text was updated successfully, but these errors were encountered: