Skip to content
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

Config with default template #162

Merged
merged 15 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated from:
# https://github.com/plone/meta/tree/master/config/default
#
# EditorConfig Configuration file, for more details see:
# http://EditorConfig.org
# EditorConfig is a convention description, that could be interpreted
# by multiple editors to enforce common coding conventions for specific
# file types

# top-most EditorConfig file:
# Will ignore other EditorConfig files in Home directory or upper tree level.
root = true


[*] # For All Files
# Unix-style newlines with a newline ending every file
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
# Set default charset
charset = utf-8
# Indent style default
indent_style = space
# Max Line Length - a hard line wrap, should be disabled
max_line_length = off

[*.{py,cfg,ini}]
# 4 space indentation
indent_size = 4

[*.{yml,zpt,pt,dtml,zcml}]
# 2 space indentation
indent_size = 2

[{Makefile,.gitmodules}]
# Tab indentation (no size specified, but view as 4 spaces)
indent_style = tab
indent_size = unset
tab_width = unset
6 changes: 0 additions & 6 deletions .isort.cfg

This file was deleted.

5 changes: 5 additions & 0 deletions .meta.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generated from:
# https://github.com/plone/meta/tree/master/config/default
[meta]
template = "default"
commit-id = "789b0936"
42 changes: 42 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generated from:
# https://github.com/plone/meta/tree/master/config/default
ci:
autofix_prs: false
autoupdate_schedule: monthly

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/collective/zpretty
rev: 3.0.2
hooks:
- id: zpretty
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
hooks:
- id: check-manifest
- repo: https://github.com/regebro/pyroma
rev: "4.2"
hooks:
- id: pyroma
8 changes: 4 additions & 4 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Bug fixes:
Bug fixes:


- Remove errorneous extra curly bracket in class name of the widget wrapper.
- Remove erroneous extra curly bracket in class name of the widget wrapper.
[thet] (#136)


Expand Down Expand Up @@ -399,7 +399,7 @@ Bug fixes:
- Fixes #64: SingleCheckBoxFieldWidget does not render value in view mode.
In order to fix this issue the hacky view was removed.
It is replaced by a new widget to render a single checkbox with bool values.
An appropiate data converter was added as well.
An appropriate data converter was added as well.
[jensens]


Expand All @@ -422,7 +422,7 @@ New features:

Bug fixes:

- Catch TypeError occuring on conflicting subrequests in inline validation
- Catch TypeError occurring on conflicting subrequests in inline validation
[tomgross]

- Clean up: code-style, zca-decorators, replace lambda.
Expand Down Expand Up @@ -501,7 +501,7 @@ New features:
whichever is specified by field.
[seanupton]

- Support functions as values in the ``pattern_options`` dictionary, whch gets then serialized to JSON.
- Support functions as values in the ``pattern_options`` dictionary, which gets then serialized to JSON.
Before that, walk recursively through ``pattern_options`` and call all functions with the widgets context.
This allows for context-specific, runtime evaluated pattern option values.
[thet]
Expand Down
2 changes: 2 additions & 0 deletions news/243ca9ec.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Update configuration files.
[plone devs]
56 changes: 32 additions & 24 deletions plone/app/z3cform/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:zcml="http://namespaces.zope.org/zcml"
xmlns:z3c="http://namespaces.zope.org/z3c"
i18n_domain="plone">
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="plone"
>

<include package="plone.z3cform" />
<include package="plone.app.widgets" />
Expand All @@ -19,25 +20,25 @@
<browser:page
name="ploneform-macros"
for="*"
layer=".interfaces.IPloneFormLayer"
class=".views.Macros"
template="templates/macros.pt"
allowed_interface="zope.interface.common.mapping.IItemMapping"
template="templates/macros.pt"
permission="zope.Public"
layer=".interfaces.IPloneFormLayer"
/>
<browser:page
name="ploneform-render-widget"
for="z3c.form.interfaces.IWidget"
layer="plone.app.z3cform.interfaces.IPloneFormLayer"
class=".views.RenderWidget"
permission="zope.Public"
layer="plone.app.z3cform.interfaces.IPloneFormLayer"
/>
<browser:page
name="ploneform-render-widget"
for="zope.contentprovider.interfaces.IContentProvider"
layer="plone.app.z3cform.interfaces.IPloneFormLayer"
class=".views.RenderContentProvider"
permission="zope.Public"
layer="plone.app.z3cform.interfaces.IPloneFormLayer"
/>

<adapter factory=".views.layout_factory" />
Expand All @@ -53,22 +54,22 @@
<!-- dexterity add/edit overrides -->
<include package="plone.dexterity" />
<adapter
factory=".views.AddView"
provides="zope.publisher.interfaces.browser.IBrowserPage"
for="Products.CMFCore.interfaces.IFolderish
plone.app.z3cform.interfaces.IPloneFormLayer
plone.dexterity.interfaces.IDexterityFTI"
provides="zope.publisher.interfaces.browser.IBrowserPage"
factory=".views.AddView"
/>
<class class=".views.AddView">
<require
permission="cmf.AddPortalContent"
interface="zope.publisher.interfaces.browser.IBrowserPage"
/>
<require
permission="cmf.AddPortalContent"
interface="zope.publisher.interfaces.browser.IBrowserPage"
/>
</class>

<browser:page
for="plone.dexterity.interfaces.IDexterityContent"
name="edit"
for="plone.dexterity.interfaces.IDexterityContent"
class=".views.EditView"
permission="cmf.ModifyPortalContent"
layer="plone.app.z3cform.interfaces.IPloneFormLayer"
Expand All @@ -86,12 +87,18 @@
<adapter factory=".converters.AjaxSelectWidgetConverter" />
<adapter factory=".converters.QueryStringDataConverter" />
<adapter factory=".converters.RelationChoiceRelatedItemsWidgetConverter" />
<adapter factory=".converters.RelationChoiceRelatedItemsWidgetConverter"
for="z3c.relationfield.interfaces.IRelationChoice .interfaces.ITextWidget" />
<adapter
factory=".converters.RelationChoiceRelatedItemsWidgetConverter"
for="z3c.relationfield.interfaces.IRelationChoice
.interfaces.ITextWidget"
/>
<adapter factory=".converters.RelationChoiceSelectWidgetConverter" />
<adapter factory=".converters.RelatedItemsDataConverter" />
<adapter factory=".converters.RelatedItemsDataConverter"
for="z3c.relationfield.interfaces.IRelationList .interfaces.ITextWidget" />
<adapter
factory=".converters.RelatedItemsDataConverter"
for="z3c.relationfield.interfaces.IRelationList
.interfaces.ITextWidget"
/>
<adapter factory=".converters.RelationListSelectWidgetDataConverter" />
<adapter factory=".converters.LinkWidgetDataConverter" />

Expand All @@ -101,20 +108,21 @@
<!-- error snippet -->
<adapter
factory=".views.ErrorViewTemplate"
for="z3c.form.interfaces.IErrorViewSnippet .interfaces.IPloneFormLayer"
provides="zope.pagetemplate.interfaces.IPageTemplate"
for="z3c.form.interfaces.IErrorViewSnippet
.interfaces.IPloneFormLayer"
/>

<utility
name="ZPublisher.HTTPRequest.FileUpload"
provides="plone.namedfile.interfaces.IStorage"
factory=".factories.Zope2FileUploadStorable"
provides="plone.namedfile.interfaces.IStorage"
name="ZPublisher.HTTPRequest.FileUpload"
/>

<utility
component=".widget.tinymce_richtextwidget_render"
provides=".interfaces.IRichTextWidgetInputModeRenderer"
name="tinymce"
/>
provides=".interfaces.IRichTextWidgetInputModeRenderer"
name="tinymce"
component=".widget.tinymce_richtextwidget_render"
/>

</configure>
8 changes: 5 additions & 3 deletions plone/app/z3cform/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from plone.app.z3cform.interfaces import ISelectWidget
from plone.app.z3cform.interfaces import ISingleCheckBoxBoolWidget
from plone.app.z3cform.interfaces import ITimeWidget
from plone.base.utils import safe_callable
from plone.uuid.interfaces import IUUID
from Products.CMFCore.utils import getToolByName
from plone.base.utils import safe_callable
from z3c.form.converter import BaseDataConverter
from z3c.form.converter import CollectionSequenceDataConverter
from z3c.form.converter import SequenceDataConverter
Expand Down Expand Up @@ -126,6 +126,7 @@ def toFieldValue(self, value):
ret = tzinfo.localize(ret)
return ret


@adapter(IDatetime, IDateWidget)
class DateWidgetToDatetimeConverter(BaseDataConverter):
"""Data converter for date widget on datetime fields."""
Expand Down Expand Up @@ -180,6 +181,7 @@ def toFieldValue(self, value):
ret = tzinfo.localize(ret)
return ret


@adapter(ITime, ITimeWidget)
class TimeWidgetConverter(BaseDataConverter):
"""Data converter for datetime fields."""
Expand Down Expand Up @@ -491,7 +493,7 @@ def toWidgetValue(self, value):
is_same_domain = utils.is_same_domain(value, portal.absolute_url())
is_absolute = utils.is_absolute(value)
if "/resolveuid/" in value and (not is_absolute or is_same_domain):
# Take the UUID part of a resolveuid url, but onl if it's on
# Take the UUID part of a resolveuid url, but only if it's on
# the same domain.
uuid = value.rsplit("/", 1)[-1]
elif not is_absolute or is_absolute and is_same_domain:
Expand All @@ -500,7 +502,7 @@ def toWidgetValue(self, value):
if parsed.params or parsed.query or parsed.fragment:
# we don't want to loose query parameters
# so we don't convert URLs pointing to internal
# objects with params, querys or fragments
# objects with params, queries or fragments
# to uids
pass
else:
Expand Down
5 changes: 1 addition & 4 deletions plone/app/z3cform/interfaces.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from plone.app.textfield.widget import (
IRichTextWidget as patextfield_IRichTextWidget,
) # noqa
from plone.app.textfield.widget import IRichTextWidget as patextfield_IRichTextWidget
from z3c.form.interfaces import IFormLayer
from z3c.form.interfaces import IRadioWidget
from z3c.form.interfaces import ISelectWidget as IBaseSelectWidget
Expand All @@ -9,7 +7,6 @@
from zope.interface import Interface
from zope.schema.interfaces import IDate
from zope.schema.interfaces import IDatetime
from zope.schema.interfaces import ITime


class IPloneFormLayer(IFormLayer):
Expand Down
5 changes: 4 additions & 1 deletion plone/app/z3cform/overrides.zcml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<configure xmlns="http://namespaces.zope.org/zope">
<includeOverrides package="plone.z3cform" file="overrides.zcml" />
<includeOverrides
package="plone.z3cform"
file="overrides.zcml"
/>
</configure>
16 changes: 9 additions & 7 deletions plone/app/z3cform/profiles.zcml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:five="http://namespaces.zope.org/five"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
xmlns:plone="http://namespaces.plone.org/plone"
i18n_domain="plone">
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:five="http://namespaces.zope.org/five"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
xmlns:plone="http://namespaces.plone.org/plone"
i18n_domain="plone"
>

<genericsetup:registerProfile
name="default"
title="Plone z3c.form support"
description="Adds support for rendering z3c.form forms in Plone"
directory="profiles/default"
provides="Products.GenericSetup.interfaces.EXTENSION"
for="plone.base.interfaces.IPloneSiteRoot"
directory="profiles/default"
/>

</configure>
5 changes: 4 additions & 1 deletion plone/app/z3cform/profiles/default/browserlayer.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<layers>
<layer name="plone.app.z3cform" interface="plone.app.z3cform.interfaces.IPloneFormLayer" />
<layer interface="plone.app.z3cform.interfaces.IPloneFormLayer"
name="plone.app.z3cform"
/>
</layers>
2 changes: 1 addition & 1 deletion plone/app/z3cform/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<version>3</version>
</metadata>
Loading