-
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
Context is not present in vocabulary factory #31
Comments
No, no solution found for the last 4 years. |
Also Maybe digging up the objects from the field object in Python debugger revealed something. At least for other DGFs fields this gives nice results. |
Ok, thanks for the info! Unfortunately, |
@pysailor hit the same problem... any outcome on this? I'm trying to work around like this:
|
You can see its a issue with zope.schema itself. in zope.schema._field
|
I just ran into this bug, trying to use a dynamic vocabulary in a dexterity object. The vocabulary content is based on the document it is called from. Works as intended when used like this:
and fails like this:
Thanks @simahawk for the hack, this will do for now! |
2018 and still the same problem. the question is: WHY is there no context? can some (hard)core dev take a look to fix that? wanting grids and fields with there context is not that exotic i guess. |
yes this is an anoying one, but with @simahawk workaround you can at least help yourself for the moment. I'm not so sure if I want to dive into z3c.form and datagridfield anytime soon ;). I added this to my vocabulary and can use it now in both Situations:
|
Two years later and I know I shouldn't have started to look into this, but here we are. I actually closed the proposed patch from #70 because I thought/read that #71 would be sufficient. After a lot of pdb'ing, to answer @iham 's question why there is not context, it's happening in this part: the pull request #70 tried to be smart to set the context on the widgets before updateWidgets on the FieldWidgets is called. But the widgets are re-instantiated in the above section of code and then the widget.context is set to self.content, which is the NO VALUE I'm too tired now to figure out with the FieldWidgets instance in the subform has this self.content set to NO VALUE, because that could lead to the newly instantiated widget getting the context. |
I have the following content type using a datagridfield. I want to use a dynamic vocabulary to compute values for a Choice field
And the vocabulary factory:
The problem is that
context
is NO_VALUE (<class 'z3c.form.interfaces.NO_VALUE'>
), so I can't do creative things using my local context. If I put the same field directly into the my IMyContent schema, the context is the object on which the field gets called.The answer to http://stackoverflow.com/questions/6623921/vocabulary-source-function-is-not-iterable-with-dexterity-in-plone-4-1 says: "I am not familiar enough with the datagrid widget setup to pinpoint where this goes wrong, but it appears that it generates widgets on-the-fly and I suspect it doesn't bind the fields for these correctly."
I spent some time in the debugger trying to find out where that might have to be done. I tried to be a smart-aleck with this hack:
But still, the same result. And to quote Mikko from #2: "...does special things deep down with z3c.form. It's a place where nobody wants to go." Indeed!
Before I give this up as a lost case: did anybody already have the same issue and maybe found a solution for it?
The text was updated successfully, but these errors were encountered: