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

Use plone.distribution and add voltodemo with testdata #35

Merged
merged 28 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6526593
Use plone.distribution and add voltodemo with testdata
pbauer Mar 7, 2024
96bde0a
use distribution when creating the site
pbauer Mar 7, 2024
403c839
update checkouts
pbauer Mar 7, 2024
95592e3
Fix create_site
pbauer Mar 7, 2024
cc1044f
Fix system block style
pbauer Mar 7, 2024
288a5b2
Some more demo content
pbauer Mar 7, 2024
129b723
fix create_site (again)
pbauer Mar 7, 2024
6a6171f
add copy of footer to customize
pbauer Mar 7, 2024
4fb247b
remove company branding
pbauer Mar 7, 2024
ac8f67f
Update setup for python 3.12
pbauer Mar 8, 2024
475d027
Add classicdemo distribution
pbauer Mar 8, 2024
e008d23
Add content to distribution
pbauer Mar 8, 2024
c279556
remove old import-data
pbauer Mar 8, 2024
168b561
make format
pbauer Mar 8, 2024
075d3db
remove obsolete checkouts and fix isort
pbauer Mar 8, 2024
6590297
Add changenote
pbauer Mar 8, 2024
0c583ad
update demo content
pbauer Mar 8, 2024
30c482d
remove checkouts after release
pbauer Mar 8, 2024
38f1613
add more example content, partly from the old vlt demo page
pbauer Mar 8, 2024
6c14603
content cleanup
pbauer Mar 8, 2024
70a67fb
hide home tab and fix zpretty
pbauer Mar 8, 2024
500c27c
update create-site script
pbauer Mar 9, 2024
7986a01
Fix making forms translatable
pbauer Mar 9, 2024
5c8a13a
fix python-version check
pbauer Mar 9, 2024
15c22c5
shamelessly steal better create-site script from plone.edu
pbauer Mar 9, 2024
953ce95
fix all references to images
pbauer Mar 9, 2024
d25c691
flake8
pbauer Mar 10, 2024
fd303d0
store form data (to be able to test form block)
pbauer Mar 12, 2024
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 2024-03-08

- Switch to plone.distribution. [pbauer]

- Add distribution voltodemo, use volto-light-theme and add some demo content. [pbauer]

- Add distribution classicdemo and add easyform. [pbauer]

# 2024-02-23

- Run a single workflow for build and deploy, twice a day. [fredvd]
Expand Down
12 changes: 8 additions & 4 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`

# Set distributions still in development
DISTRIBUTIONS="voltodemo"
ALLOWED_DISTRIBUTIONS="voltodemo"

PLONE_VERSION=6.0.10.1

BACKEND_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
Expand Down Expand Up @@ -42,7 +46,7 @@ endif
# version ok?
PYTHON_VERSION_MIN=3.8
PYTHON_VERSION_OK=$(shell $(PYTHON) -c "import sys; print((int(sys.version_info[0]), int(sys.version_info[1])) >= tuple(map(int, '$(PYTHON_VERSION_MIN)'.split('.'))))")
ifeq ($(PYTHON_VERSION_OK),0)
ifeq ($(PYTHON_VERSION_OK),False)
$(error "Need python $(PYTHON_VERSION) >= $(PYTHON_VERSION_MIN)")
endif

Expand Down Expand Up @@ -87,7 +91,7 @@ clean-test: ## remove test and coverage artifacts
bin/pip:
@echo "$(GREEN)==> Setup Virtual Env$(RESET)"
$(PYTHON) -m venv .
bin/pip install -U "pip" "wheel" "cookiecutter" "mxdev"
bin/pip install -U "setuptools" "pip" "wheel" "cookiecutter" "mxdev"

.PHONY: config
config: bin/pip ## Create instance configuration
Expand Down Expand Up @@ -150,8 +154,8 @@ test_quiet: ## run tests removing deprecation warnings
PYTHONWARNINGS=ignore ./bin/zope-testrunner --auto-color --auto-progress --test-path src/plone6demo/src/

.PHONY: create-site
create-site: instance/etc/zope.ini ## Create a new site from scratch
PYTHONWARNINGS=ignore ./bin/zconsole run instance/etc/zope.conf ./scripts/create_site.py
create-site: ## Create a new site using default distribution and default answers
DEVELOP_DISTRIBUTIONS=$(DISTRIBUTIONS) ALLOWED_DISTRIBUTIONS=$(DISTRIBUTIONS) PYTHONWARNINGS=ignore ./bin/zconsole run instance/etc/zope.conf scripts/create-site.py

.PHONY: start
start: ## Start a Plone instance on localhost:8080
Expand Down
3 changes: 1 addition & 2 deletions backend/instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ default_context:
initial_user_name: 'admin'
initial_user_password: 'admin'

load_zcml:
package_includes: ['plone6demo']
zcml_package_includes: 'plone6demo'

db_storage: direct
98 changes: 98 additions & 0 deletions backend/scripts/create-site.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
from AccessControl.SecurityManagement import newSecurityManager
from pathlib import Path
from plone.distribution.api import site as site_api
from Testing.makerequest import makerequest

import json
import logging
import os
import transaction


logging.basicConfig(format="%(message)s")

# Silence some loggers
for logger_name in [
"GenericSetup.componentregistry",
"Products.MimetypesRegistry.MimeTypesRegistry",
]:
logging.getLogger(logger_name).setLevel(logging.ERROR)

logger = logging.getLogger("Plone Site Creation")
logger.setLevel(logging.DEBUG)

SCRIPT_DIR = Path().cwd() / "scripts"

truthy = frozenset(("t", "true", "y", "yes", "on", "1"))


def asbool(s):
"""Return the boolean value ``True`` if the case-lowered value of string
input ``s`` is a :term:`truthy string`. If ``s`` is already one of the
boolean values ``True`` or ``False``, return it."""
if s is None:
return False
if isinstance(s, bool):
return s
s = str(s).strip()
return s.lower() in truthy


app = makerequest(globals()["app"])

request = app.REQUEST

admin = app.acl_users.getUserById("admin")
admin = admin.__of__(app.acl_users)
newSecurityManager(None, admin)


def get_answers_file() -> Path:
filename = f"{ANSWERS}.json"
return SCRIPT_DIR / filename


def parse_answers(answers_file: Path, site_id: str = "") -> dict:
answers = json.loads(answers_file.read_text())
if "distribution" not in answers:
# This is a bug in plone.distribution and should be fixed there
answers["distribution"] = DISTRIBUTION
if site_id:
answers["site_id"] = site_id
return answers


# VARS
DISTRIBUTION = os.getenv("DISTRIBUTION", "voltodemo")
SITE_ID = os.getenv("SITE_ID") # if set, this overrides the value in ANSWERS
ANSWERS = os.getenv("ANSWERS", "default")
DELETE_EXISTING = asbool(os.getenv("DELETE_EXISTING"))

# Load site creation parameters
answers_file = get_answers_file()
answers = parse_answers(answers_file, SITE_ID)
site_id = answers["site_id"]


logger.info(f"Creating a new Plone site @ {site_id}")
logger.info(f" - Using the {DISTRIBUTION} distribution and answers from {answers_file}")


if site_id in app.objectIds() and DELETE_EXISTING:
app.manage_delObjects([site_id])
transaction.commit()
app._p_jar.sync()
logger.info(f" - Deleted existing site with id {site_id}")
else:
logger.info(
f" - Stopping site creation, as there is already a site with id {site_id}. "
"Set DELETE_EXISTING=1 to delete the existing site before creating a new one."
)

if site_id not in app.objectIds():
site = site_api._create_site(
context=app, distribution_name=DISTRIBUTION, answers=answers
)
transaction.commit()
app._p_jar.sync()
logger.info(" - Site created!")
62 changes: 0 additions & 62 deletions backend/scripts/create_site.py

This file was deleted.

8 changes: 8 additions & 0 deletions backend/scripts/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"site_id": "Plone",
"title": "Welcome to Plone 6",
"description": "Site created with a new Plone Distribution",
"default_language": "en",
"portal_timezone": "Europe/Berlin",
"setup_content": true
}
8 changes: 7 additions & 1 deletion backend/src/plone6demo/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Installer for the plone6demo package."""

from setuptools import find_packages
from setuptools import setup

Expand All @@ -22,9 +23,13 @@
"Framework :: Plone",
"Framework :: Plone :: Addon",
"Framework :: Plone :: 6.0",
"Framework :: Plone :: Distribution",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: OS Independent",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
],
Expand All @@ -46,8 +51,9 @@
install_requires=[
"setuptools",
"Plone",
"prettyconf",
"plone.api",
"plone.distribution",
"collective.volto.formsupport",
],
extras_require={
"test": [
Expand Down
12 changes: 12 additions & 0 deletions backend/src/plone6demo/src/plone6demo/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:plone="http://namespaces.plone.org/plone"
i18n_domain="plone6demo"
>

Expand All @@ -14,6 +15,10 @@
package="plone.behavior"
file="meta.zcml"
/>
<include
package="plone.distribution"
file="meta.zcml"
/>

<include file="dependencies.zcml" />

Expand All @@ -28,4 +33,11 @@
<include package=".services" />
<include package=".subscribers" />

<plone:distribution
name="voltodemo"
title="Volto Demo Site"
description="A Plone 6 Site with demo content"
directory="distributions/voltodemo"
/>

</configure>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading