Skip to content

Commit

Permalink
Merge pull request #7 from plone/config-with-default-template-fe7626df
Browse files Browse the repository at this point in the history
Config with default template
  • Loading branch information
jensens authored Apr 23, 2023
2 parents fe7626d + 40a0563 commit 782b8da
Show file tree
Hide file tree
Showing 18 changed files with 327 additions and 131 deletions.
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
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 = "2ed8f544"
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.3.0
hooks:
- id: black
- repo: https://github.com/collective/zpretty
rev: 3.0.3
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.4
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
2 changes: 2 additions & 0 deletions news/1.breaking
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Drop python 2.7 support.
[gforcada]
2 changes: 2 additions & 0 deletions news/2ed8f544.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Update configuration files.
[plone devs]
3 changes: 1 addition & 2 deletions plone/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
__import__('pkg_resources').declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__)
1 change: 0 additions & 1 deletion plone/uuid/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
4 changes: 1 addition & 3 deletions plone/uuid/adapter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from plone.uuid import interfaces
from zope import component
from zope import interface
Expand All @@ -12,8 +11,7 @@ def attributeUUID(context):

@interface.implementer(interfaces.IMutableUUID)
@component.adapter(interfaces.IAttributeUUID)
class MutableAttributeUUID(object):

class MutableAttributeUUID:
def __init__(self, context):
self.context = context

Expand Down
14 changes: 2 additions & 12 deletions plone/uuid/browser.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
# -*- coding: utf-8 -*-
from plone.uuid.interfaces import IUUID
from zope.publisher.browser import BrowserView

import sys


if sys.version_info >= (3,):
text_type = str
else:
text_type = unicode


class UUIDView(BrowserView):
"""A simple browser view that renders the UUID of its context
"""
"""A simple browser view that renders the UUID of its context"""

def __call__(self):
return text_type(IUUID(self.context, u""))
return str(IUUID(self.context, ""))
19 changes: 12 additions & 7 deletions plone/uuid/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:zcml="http://namespaces.zope.org/zcml"
xmlns:i18n="http://namespaces.zope.org/i18n"
i18n_domain="plone.uuid">
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="plone.uuid"
>

<include package="zope.component" file="meta.zcml" />
<include
package="zope.component"
file="meta.zcml"
/>
<include package="zope.component" />

<!-- Make sure we test the Zope 2 version of view registrations in Zope 2 -->
<include zcml:condition="installed Products.Five" package="Products.Five.browser" file="meta.zcml" />
<include zcml:condition="not-installed Products.Five" package="zope.browserpage" file="meta.zcml" />
<include
package="zope.browserpage"
file="meta.zcml"
/>

<adapter factory=".adapter.attributeUUID" />
<adapter factory=".adapter.MutableAttributeUUID" />
Expand All @@ -19,8 +24,8 @@

<browser:view
name="uuid"
class=".browser.UUIDView"
for=".interfaces.IUUIDAware"
class=".browser.UUIDView"
permission="zope.Public"
/>

Expand Down
13 changes: 1 addition & 12 deletions plone/uuid/generator.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
# -*- coding: utf-8 -*-
from plone.uuid.interfaces import IUUIDGenerator
from zope.deprecation import deprecate
from zope.interface import implementer

import uuid


@implementer(IUUIDGenerator)
class UUID4Generator(object):
class UUID4Generator:
"""Default UUID implementation.
Uses uuid.uuid4()
"""

def __call__(self):
return uuid.uuid4().hex


@deprecate(
'UUID1Generator was renamed to UUID4Generator, as we use uuid4 instead of '
'uuid1. Please use UUID4Generator instead.'
)
class UUID1Generator(UUID4Generator):
"""BBB. Remove with next major version.
"""
7 changes: 4 additions & 3 deletions plone/uuid/handlers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from plone.uuid.interfaces import ATTRIBUTE_NAME
from plone.uuid.interfaces import IAttributeUUID
from plone.uuid.interfaces import IUUIDGenerator
Expand All @@ -11,12 +10,14 @@
try:
from Acquisition import aq_base
except ImportError:
aq_base = lambda v: v # soft-dependency on Zope2, fallback

def aq_base(obj):
# soft-dependency on Zope2, fallback
return obj


@adapter(IAttributeUUID, IObjectCreatedEvent)
def addAttributeUUID(obj, event):

if not IObjectCopiedEvent.providedBy(event):
if getattr(aq_base(obj), ATTRIBUTE_NAME, None):
return # defensive: keep existing UUID on non-copy create
Expand Down
13 changes: 5 additions & 8 deletions plone/uuid/interfaces.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# -*- coding: utf-8 -*-
from zope.interface import Interface


ATTRIBUTE_NAME = '_plone.uuid'
ATTRIBUTE_NAME = "_plone.uuid"


class IUUIDGenerator(Interface):
"""Utility for generating UUIDs
"""
"""Utility for generating UUIDs"""

def __call__():
"""Generate a new UUID.
"""
"""Generate a new UUID."""


class IUUIDAware(Interface):
Expand Down Expand Up @@ -43,9 +40,9 @@ class IMutableUUID(Interface):
Be sure of what you are doing. UUID is supposed to be stable and
widely used
"""

def get():
"""Return the UUID of the context"""

def set(uuid):
"""Set the unique id of the context with the uuid value.
"""
"""Set the unique id of the context with the uuid value."""
Loading

0 comments on commit 782b8da

Please sign in to comment.