[Zope3-Users] Generate edit form from user setting

Florian Lindner mailinglists at xgm.de
Tue Aug 22 07:07:33 EDT 2006

Am Donnerstag, 17. August 2006 23:04 schrieb Fred Drake:
> On 8/17/06, Florian Lindner <mailinglists at xgm.de> wrote:
> > I have a zope.app.preference.preference.PreferenceGroup based on an
> > IUserSettings interface for which I want to generate an edit form.
> > I've tried to do it with a class based on EditForm but that does not
> > worked for me since the EditFrom changes the self.context object. If I
> > simply replace self.context by the object I got from UserPreferences it
> > complains about PreferenceGroup being not adaptable to IUserSettings (and
> > it's right about that).
> Sounds like you want to create an adapter.  The adapter is what's used
> for getting/setting values.

I also thought about that. But if I write an adapter from PreferenceGroup to 
IUserSettings to all that the adapter would do is to assign values the values 
from the PreferenceGroup to IUserSettings. Ok it's more generic but at the 
end the same like assigned the values to the request itself.

Is it okay to change self.context in the __init__ method of the view class 
with a PreferenceGroup object? (I just didn't know it it's not confusing the 
something in the ComponentArchitecture...)

> > Of course I need to initialize the from with the values from the the
> > PreferenceGroup object. Is there a better way than modifying the request
> > like request.form['form.max_size'] for each field? I couldn't find one in
> > the documentation but I'm almost sure there is a more elegant solution
> > (since it's Zope!).
> Did you look at the get_rendered argument to
> zope.formlib.form.FormField?  Though I suspect the adapter I suggested
> above would do the trick.

Mmmhh, that's also one call for each field. I think I'll try it with the 



More information about the Zope3-users mailing list