zopefoundation / z3c.form

An advanced form and widget framework for Zope 3
Other
9 stars 39 forks source link

definition of "root" is missing in the example used to introduce "Forms" #91

Closed gamboz closed 4 years ago

gamboz commented 4 years ago

In the documentation of Forms, an object named root is used, but I think that it is never defined.

In https://github.com/zopefoundation/z3c.form/blob/master/src/z3c/form/form.rst the following code uses "root" (l.139) addForm = PersonAddForm(root, request) some lines before (l.134), it is stated that the "root" folder had been created during setup (I think it refers to l.18 testing.setupFormDefaults()), but I cannot find this "root" object.

I'm running the code of form.rst from a working installation of Plone5.2:

cd zinstance
. bin/activate
zopepy

(I'm a bit new to this, so it may be that I'm missing something basic...)

icemac commented 4 years ago

root is defined here: https://github.com/zopefoundation/z3c.form/blob/9d6d83c71d8b83752a0dde162ef358116a804564/src/z3c/form/testing.py#L251

Closing the issue as invalid because this is not a bug in z3c.form.

gamboz commented 4 years ago

thanks for the quick reply; I see that 'root' is defined, but if I follow the instructions in the aforementioned page, I think I get an error. How should I invoke addForm = PersonAddForm(???, request) to use "root"? (I apologize if this question is wrong, but I still think there might be an error in the documentation)

icemac commented 4 years ago

@gamboz You use the site object which is created behind the scenes for the test in testing.py. It is bound to the name root by the code I referenced above.