Plone 5.2 upgrade guide

In case anyone is working on Plone 5.2 upgrades, the upgrade guide is not yet up on docs.plone.org but can be found here:

Information on the Plone add-ons that are being migrated to Python 3:

Would it be an idea to document 'what common imports (etc)' to use while planning to upgrade add-ons for Python 3' ?

Without knowing too much about it, it looks to me that some add-ons use:
from plone.directives import form and then form.schema
while others use model.schema

and 'form.widget' have been imported from plone.directives and auto form (??)

Never import from plone.directives. It is deprecated.

Thanks Espen - I would think that someone would have started such a document already but I haven’t looked and I’m not aware of it. Maybe you could start one if you don’t find one.

… if I only know what was correct :wink:

I tried to find out 'where things have moved'.

plone.directives.form explains that widget and schema should be imported from plone.supermodel and plone.autoform, but I could not find out from where to import buttons (etc)

I found some Forms defined with:

plone.directives.form.SchemaForm

is this available through another import, or what is the correct approach for porting these forms to 5.2 ?

plone.directives is gone, all directives are available from `plone.autoform.directivesorplone.supermodel.directives``.

I was looking for info about how to update a form that is using plone.directives.form to work with Plone 5.2 and python 3 and I landed on this thread.
I'll post here how I did it, hoping it can be useful to other people.

The part that was hard to find for me was that if your view inherited from plone.directives.form.SchemaForm,
you need to update your code to inherit from z3c.form.form.Form and plone.autoform.form.AutoExtensibleForm.

Before:

myform.py

from five import grok
from plone.directives import form
from myproduct.interfaces import MyInterface

class MyForm(form.SchemaForm):
    grok.name('myform-name')
    grok.require('cmf.ManagePortal')
    grok.context(MyInterface)
    schema = IMyForm

After:

configure.zcml

  <browser:page
    for="myproduct.interfaces.MyInterface"
    name="import-form"
    permission="cmf.ManagePortal"
    class=".import_content.ImportForm"
  />

myform.py

from z3c.form import form
from plone.autoform.form import AutoExtensibleForm
 
 
class MyForm(AutoExtensibleForm, form.Form):
    schema = IMyForm

Maybe we should also mention that 'widget syntax' is now:

from plone.autoform import directives

directives.widget(
    'myfield', SomeFieldWidget