Ticket #12253 (closed PLIP: fixed)

Opened 4 years ago

Last modified 17 months ago

Use z3c.form instead of zope.formlib in plone.app.users

Reported by: khink Owned by: piv
Priority: minor Milestone: 5.0
Component: General Version:
Keywords: Cc: timo, lentinj

Description (last modified by lentinj) (diff)

Proposer: Kees Hink
Seconder: Timo Stollenwerk
Implementers: Vitaliy Podoba and Jamie Lentin


Motivation

Replacing zope.formlib with z3c.form in plone.app.users would have these benefits:

  • conform to coding best practice (formlib is not widely used anymore, z3c.form is more of a standard)
  • z3c.form is better documented and allows more flexible form creation
  • Plone 4 officially includes z3c.form, so this is one less reason to stick with formlib
  • it'll allow form developers to use growing number of rich z3c.form widgets
  • there are other similar PLIPs to move Plone control panels, portlets, etc... to z3c.form, so with this PLIP we'll be one more step closer to "all formlib Plone forms to z3c.form" milestone

Assumptions

The main idea is to have both versions at the moment: formlib (still as a default one) and z3c.form. So that developer that needs to have benefits of z3c.form form versions will be able to switch to using it.

Later, we may decide when to completely remove formlib forms from the package.

So we do not make everybody update there addons or customized code for client projects, this would start just as optional feature for those that really need it.

Another thing here is to make underlying code use z3c.form library, and not to change any UI or settings storage.

To make a shift easier for developers collective.examples.userdata should also be updated to showcase plone.app.users usage with z3c forms.

Proposal & Implementation

We'll try not to touch formlib forms as much as possible. And will introduce z3c.form form versions which will be enabled optionally by developer with the next inclusions:

<include package="plone.app.users.browser" file="z3c-configure.zcml" />
<include package="plone.app.users.browser" file="z3c-overrides.zcml" />

This is a list of the forms that will have it's z3c.form clone:

  • personal information + configlet
  • personal preferences + configlet
  • change password
  • registration form + add new user form
  • @@member-registration control panel

Instead of using IUserDataSchemaProvider approach to extend personal information form we'll use IFormExtender (from plone.z3cform.fieldsets package) technique to allow developer extend personal information, registration and add new user forms.

Thus @@member-registration control panel will allow to manipulate only default list of registration fields. Everything else should be managed within Form Extender.

To set/get extra member data, we'll still use the same schema adapter approach.

Also collective.examples.userdata will be updated to showcase how to extend user forms using IFormExtender approach.

Deliverables

  • added more high level tests to plone.app.users package that would work after migration to z3c.form
  • updated plone.app.users code base to use z3c.form library and pass high level tests
  • updated plone.app.users README.txt to explain how to extend z3c forms
  • moved to github collective.examples.userdata and updated to work with new plone.app.users z3c.form-based forms

Risks

Having z3c.form forms only as optional feature, there shouldn't be any backwards compatibility issues. If developer switched to using z3c.form, this is under his/her responsibility to update code to make it work with z3c forms.

Formlib forms are not going to be touched at all.

Participants

  • Timo Stollenwerk (timo)
  • Vitaliy Podoba (piv)
  • Jamie Lentin (lentinj)

Progress

Everything from plip12253-review-rpatterson.rst and plip12253-review-davisagli.rst should be addressed now, so ready for review again.

Code branches:

TODO left:  https://github.com/plone/plone.app.users/blob/plip12253-use-z3c.form/plone/app/users/TODO.txt

If PLIP is confirmed I'll prepare PLIP buildout configuration and notes files for Framework Team to review.

Additional Notes

See also these discussions on the plone-dev mailinglist:

Change History

comment:1 Changed 4 years ago by timo

  • Cc timo added; tisto removed
  • Description modified (diff)

comment:2 Changed 4 years ago by esteele

The Framework Team would be happy to review this. First, please follow the PLIP format, to make their lives easier. Thanks!

comment:3 Changed 4 years ago by khink

  • Version set to 4.1

Dear Framework Team,

No work is being done on this at the moment. Both Timo and i can't find time to work on it. We still think it's a good idea and hope to come back to it in the future.

comment:4 Changed 4 years ago by eleddy

  • Status changed from new to confirmed
  • Version changed from 4.1 to 4.2
  • Milestone set to 4.x

comment:5 Changed 4 years ago by davisagli

  • Component changed from Infrastructure to General

comment:6 Changed 4 years ago by fakedrake

Are there any updates on this? I think I can loosely start working on this if nobody else is ATM

comment:7 Changed 4 years ago by timo

Not that I would know. Kees and I won't have the time to work on this. It would be awesome if you would start working on it. First thing to do would be to update the PLIP according to the right format I guess.

comment:8 Changed 4 years ago by fakedrake

Is there a guide for that?

comment:9 Changed 4 years ago by timo

As far as I know there is no guide. I'm currently working on converting the control panels to use z3c.form (https://dev.plone.org/ticket/10359,  https://github.com/plone/plone.app.controlpanel/tree/plip10359-z3cform), so I guess you could have a look there to get some ideas.

What I do when I convert a control panel to use z3c.form is that I start with writing some high-level functional tests (or complete the existing ones) to make sure the new z3c.form works exactly as the formlib form (before I write a single line of code). See for instance:

 https://github.com/plone/plone.app.controlpanel/blob/plip10359-z3cform/plone/app/controlpanel/tests/navigation.txt

After that I write integration/unit tests and start replacing the formlib form with z3c.form forms. For plone.app.controlpanel I use plone.app.registry to generate the form, so I guess these are not good examples. In the beginning I wrote some proof-of-concept code with plone.autoform though:

 https://github.com/plone/plone.app.controlpanel/commit/91d0c2f93c12c424f458d5d4515ba63a957b6eb0

Feel free to ping me on irc (tisto) if you need further assistance.

comment:10 Changed 3 years ago by piv

  • Cc piv added

comment:11 Changed 3 years ago by piv

  • Version changed from 4.2 to 4.3
  • Description modified (diff)

comment:12 Changed 3 years ago by piv

  • Owner set to piv
  • Status changed from confirmed to assigned

I've just updated ticket description to conform with PLIP formatting. Please, review proposal and let me know of any issues you find in it. Thank you!

comment:13 Changed 3 years ago by piv

  • Cc piv removed

comment:14 Changed 3 years ago by piv

  • Cc lentinj added
  • Description modified (diff)

comment:15 Changed 3 years ago by davisagli

  • Version 4.3 deleted
  • Milestone changed from 4.x to 4.4

Congratulations, the framework team has approved this proposal to be implemented for Plone 4.4. We would like to deprecate the formlib forms and then remove them in Plone 5.0. Please let me know when this is ready for review and where to find the review buildout.

comment:16 Changed 3 years ago by khink

  • Description modified (diff)

removed myself from participants - haven't done anything on this, effectively.

comment:17 Changed 3 years ago by piv

I just added technical notes file for this PLIP. There you'll find buildout configuration and some other notes re implementation. Please, check:  https://github.com/plone/buildout.coredev/blob/4.3/plips/implementation_notes/plip12253-users-z3cform.txt

If there are any issues with running buildout, please, let me know.

comment:18 Changed 3 years ago by seanupton

I assume we will want to port this change (mine) to z3c.form to live in harmony with PLIP 10886 (user timezone in default user preferences form).  https://github.com/plone/plone.app.users/commit/1f99ca05a843fe820407d5ba509a4f3d8beb1995

comment:19 Changed 3 years ago by rossp

Added a review:

 https://github.com/plone/buildout.coredev/commit/9b65275a97bc32a317783e7df4a18778100423ab

-1 for now, needs work before I can give a +1 for merging. Can the implementers take a look at my feedback and advise what they think they can address by the merge deadline?

comment:20 Changed 3 years ago by davisagli

Added a review:

 https://github.com/plone/buildout.coredev/commit/c9476fef54eceddd7e6d8b14b181e488ba75776c

-1 but it won't take a lot more work to get it there.

comment:21 Changed 3 years ago by piv

Thank you guys for your reviews. I agree on most of the points, and will provide updates within the next 1-2 weeks.

comment:22 Changed 3 years ago by esteele

  • Milestone changed from 4.4 to 5.0

The Framework Team has decided to move on to Plone 5. Updating milestones accordingly.

comment:23 Changed 3 years ago by davisagli

Did you ever get a chance to work on this, Vitaliy? We'd love to be able to include it in Plone 5.

comment:24 Changed 3 years ago by piv

Unfortunately no. I'm not sure if I'll be able to finish it now honestly saying.

BTW, what about other plone.app.users related PLIPs, like editing user schema via Plone UI. Does it influence this PLIP in any way?

Last edited 3 years ago by piv (previous) (diff)

comment:25 Changed 3 years ago by thet

  • Description modified (diff)

comment:26 Changed 2 years ago by thet

Since i have a customer project, where we need customized registration forms and want to build upon a future-proof foundation, I'll take on this one. I already started on merging with master and removing the formlib part and backporting the changes since the last master-merge. I'll continue tomorrow and push the changes then.

comment:27 Changed 2 years ago by lentinj

Sorry, completely forgot about this. Working on it as part of the Arnhem sprint though, picked out remaining issues from the reviews and added them to plone/app/users/TODO.txt.

I've also updated collective.examples.userdata to work against the p.a.users again.

comment:28 Changed 2 years ago by piv

Sorry, I have no chance to return back to it and finish Reviewers notes any soon.

comment:29 Changed 2 years ago by lentinj

Right, I think pretty much everything is solved and ready for review. The main issue left is what to do about @@member-registration (i.e. the panel when you choose which user data fields go into the register form).

Without extending the user data form, everything works as you might expect. However, if you use FormExtenders on UserDataPanel in the way that collective.examples.userdata suggests, any additional fields won't be available for selection in @@member-registration. You have to extend the BaseRegistrationForm too if you want to achieve this.

In a way, I like how things work at the moment since if you've already registered one extender then doing a second is probably easier than remembering there's a random config option to play with. Also, once this is merged, you could register a FormExtender that added a schema edited TTW, and that could have it's own facility for adding to the registration form or not.

However, is the fields you added not appearing in @@member-registration confusing for existing Plone people?

I do wonder if the form schemas shouldn't be trying to steal each other's fields, instead it should be one all-encompassing form/schema that omits various options based on whether it's a register, add user, or user information form. This might simplify matters.

comment:30 Changed 2 years ago by lentinj

  • Description modified (diff)

comment:31 Changed 2 years ago by thet

comment:32 Changed 17 months ago by ebrehault

Pull request has been merged one year ago. We should close this ticket, right ?

comment:33 Changed 17 months ago by lentinj

  • Status changed from assigned to closed
  • Resolution set to fixed

Yes, it's all been done.

Note: See TracTickets for help on using tickets.