-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch: refs/heads/main Date: 2025-01-22T17:21:53+01:00 Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> Commit: plone/plone.distribution@c12ee5b Include revisions only when passing --include-revisions. This needs plone/plone.exportimport#44. It would be good to have that merged and in a release, so we can add that release as minimum version in our dependencies. Files changed: A news/39.feature M README.md M src/plone/distribution/cli/__init__.py Repository: plone.distribution Branch: refs/heads/main Date: 2025-01-23T23:26:40+01:00 Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> Commit: plone/plone.distribution@191d265 Require plone.exportimport 1.0.0b1 as minimum. This is needed for the --include-revisions option. Files changed: M setup.py Repository: plone.distribution Branch: refs/heads/main Date: 2025-01-27T10:40:48-08:00 Author: David Glick (davisagli) <david@glicksoftware.com> Commit: plone/plone.distribution@1164162 Merge pull request #108 from plone/maurits-optional-include-versions Include revisions only when passing --include-revisions. Files changed: A news/39.feature M README.md M setup.py M src/plone/distribution/cli/__init__.py
- Loading branch information
Showing
1 changed file
with
50 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,57 @@ | ||
Repository: plone.restapi | ||
Repository: plone.distribution | ||
|
||
|
||
Branch: refs/heads/main | ||
Date: 2025-01-27T08:48:48-08:00 | ||
Author: Mauro Amico (mamico) <mauro.amico@gmail.com> | ||
Commit: https://github.com/plone/plone.restapi/commit/3830080c59daf497880046022521ab8cdb10ee7a | ||
|
||
AttributeError occurs in creator_name when the user is missing (#1867) | ||
|
||
* AttributeError occurs in creator_name when the user is missing | ||
|
||
* changelog | ||
|
||
* userid | ||
|
||
* Update news/1867.bugfix | ||
|
||
--------- | ||
|
||
Co-authored-by: David Glick <david@glicksoftware.com> | ||
Date: 2025-01-22T17:21:53+01:00 | ||
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> | ||
Commit: https://github.com/plone/plone.distribution/commit/c12ee5b43d4c902144c7063ded2a3153daf87235 | ||
|
||
Include revisions only when passing --include-revisions. | ||
|
||
This needs https://github.com/plone/plone.exportimport/pull/44. | ||
It would be good to have that merged and in a release, so we can add that release as minimum version in our dependencies. | ||
|
||
Files changed: | ||
A news/39.feature | ||
M README.md | ||
M src/plone/distribution/cli/__init__.py | ||
|
||
b'diff --git a/README.md b/README.md\nindex 72ee071..576390d 100644\n--- a/README.md\n+++ b/README.md\n@@ -293,11 +293,14 @@ Folder containing JSON data representing this distribution\'s content.\n To export content from a site into this folder, use the `bin/export-distribution` script.\n \n ```shell\n-bin/export-distribution path/to/zope.conf Plone\n+bin/export-distribution [--include-revisions] path/to/zope.conf Plone\n ```\n \n > In the example above, "Plone" is the ID of the Plone site to export.\n \n+By default, the revisions history (older versions of each content item) are not exported.\n+If you do want them, add `--include-revisions` on the command line.\n+\n ## Advanced Usage\n \n ### Hiding Distributions\ndiff --git a/news/39.feature b/news/39.feature\nnew file mode 100644\nindex 0000000..0c2a4f6\n--- /dev/null\n+++ b/news/39.feature\n@@ -0,0 +1 @@\n+Include revisions only when passing `--include-revisions`. @mauritsvanrees\ndiff --git a/src/plone/distribution/cli/__init__.py b/src/plone/distribution/cli/__init__.py\nindex 4ab63d6..208f4a5 100644\n--- a/src/plone/distribution/cli/__init__.py\n+++ b/src/plone/distribution/cli/__init__.py\n@@ -13,6 +13,7 @@\n "options": {\n "zopeconf": "Path to zope.conf",\n "site": "Plone site ID to export the content from",\n+ "--include-revisions": "Include revision history",\n },\n },\n }\n@@ -21,7 +22,10 @@\n def _parse_args(description: str, options: dict, args: list):\n parser = argparse.ArgumentParser(description=description)\n for key, help in options.items():\n- parser.add_argument(key, help=help)\n+ if key.startswith("-"):\n+ parser.add_argument(key, action="store_true", help=help)\n+ else:\n+ parser.add_argument(key, help=help)\n namespace, _ = parser.parse_known_args(args[1:])\n return namespace\n \n@@ -30,6 +34,7 @@ def export(args=sys.argv):\n """Export a Plone site to a distribution."""\n logger = cli_helpers.get_logger("Exporter")\n exporter_cli = CLI_SPEC["exporter"]\n+ # We get an argparse.Namespace instance.\n namespace = _parse_args(exporter_cli["description"], exporter_cli["options"], args)\n app = cli_helpers.get_app(namespace.zopeconf)\n site = cli_helpers.get_site(app, namespace.site, logger)\n@@ -41,6 +46,6 @@ def export(args=sys.argv):\n logger.info(f"Exporting Plone site at /{site.id}")\n logger.info(f" Target path: {path}")\n with api.env.adopt_roles(["Manager"]):\n- results = get_exporter(site).export_site(path)\n+ results = get_exporter(site).export_site(path, options=namespace)\n for item in results[1:]:\n logger.info(f" Wrote {item.relative_to(path)}")\n' | ||
|
||
Repository: plone.distribution | ||
|
||
|
||
Branch: refs/heads/main | ||
Date: 2025-01-23T23:26:40+01:00 | ||
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> | ||
Commit: https://github.com/plone/plone.distribution/commit/191d265900cbcbf4c98194102420f6f7a18da27a | ||
|
||
Require plone.exportimport 1.0.0b1 as minimum. | ||
|
||
This is needed for the --include-revisions option. | ||
|
||
Files changed: | ||
M setup.py | ||
|
||
b'diff --git a/setup.py b/setup.py\nindex 247f835..6158741 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -55,7 +55,7 @@\n "plone.api",\n "plone.base",\n "plone.dexterity",\n- "plone.exportimport>=1.0.0a5",\n+ "plone.exportimport>=1.0.0b1",\n "plone.i18n",\n "plone.protect",\n "plone.rest",\n' | ||
|
||
Repository: plone.distribution | ||
|
||
|
||
Branch: refs/heads/main | ||
Date: 2025-01-27T10:40:48-08:00 | ||
Author: David Glick (davisagli) <david@glicksoftware.com> | ||
Commit: https://github.com/plone/plone.distribution/commit/116416260045f295396c3065e870218e51f453f1 | ||
|
||
Merge pull request #108 from plone/maurits-optional-include-versions | ||
|
||
Include revisions only when passing --include-revisions. | ||
|
||
Files changed: | ||
A news/1867.bugfix | ||
M src/plone/restapi/services/locking/__init__.py | ||
M src/plone/restapi/tests/test_locking.py | ||
A news/39.feature | ||
M README.md | ||
M setup.py | ||
M src/plone/distribution/cli/__init__.py | ||
|
||
b'diff --git a/news/1867.bugfix b/news/1867.bugfix\nnew file mode 100644\nindex 000000000..f4ddcaac8\n--- /dev/null\n+++ b/news/1867.bugfix\n@@ -0,0 +1 @@\n+In the `@locking` endpoint, fixed edge cases where the user who owns the lock was not found correctly. @mamico\ndiff --git a/src/plone/restapi/services/locking/__init__.py b/src/plone/restapi/services/locking/__init__.py\nindex 1b22e975a..c9347a7b4 100644\n--- a/src/plone/restapi/services/locking/__init__.py\n+++ b/src/plone/restapi/services/locking/__init__.py\n@@ -7,14 +7,17 @@\n from plone.locking.interfaces import ILockable\n \n \n-def creator_name(username):\n- user = api.user.get(username=username)\n- return user.getProperty("fullname") or username\n+def creator_name(userid):\n+ user = api.user.get(userid=userid)\n+ if user:\n+ return user.getProperty("fullname") or userid\n+ else:\n+ return userid\n \n \n-def creator_url(username):\n+def creator_url(userid):\n url = api.portal.get().absolute_url()\n- return f"{url}/author/{username}"\n+ return f"{url}/author/{userid}"\n \n \n def creation_date(timestamp):\ndiff --git a/src/plone/restapi/tests/test_locking.py b/src/plone/restapi/tests/test_locking.py\nindex 191b4d6bd..40e7fc5b8 100644\n--- a/src/plone/restapi/tests/test_locking.py\n+++ b/src/plone/restapi/tests/test_locking.py\n@@ -1,3 +1,4 @@\n+from plone import api\n from plone.app.testing import login\n from plone.app.testing import SITE_OWNER_NAME\n from plone.app.testing import SITE_OWNER_PASSWORD\n@@ -112,3 +113,45 @@ def test_update_locked_object_with_token_succeeds(self):\n transaction.commit()\n self.assertEqual(response.status_code, 204)\n self.assertEqual(self.doc.Title(), "New Title")\n+\n+ def test_lock_user_removed(self):\n+ lockable = ILockable(self.doc)\n+ api.user.create(\n+ username="foo",\n+ email="foo@bar.com",\n+ roles=["Manager"],\n+ )\n+ with api.env.adopt_user(username="foo"):\n+ lockable.lock()\n+ api.user.delete(username="foo")\n+ transaction.commit()\n+ # the user that locked the object is no longer present\n+ response = self.api_session.get("/@lock")\n+ self.assertEqual(response.status_code, 200)\n+ self.assertEqual(response.json()["creator"], "foo")\n+ self.assertEqual(response.json()["creator_name"], "foo")\n+ self.assertTrue(lockable.locked())\n+\n+ def test_lock_username_vs_userid(self):\n+ lockable = ILockable(self.doc)\n+ api.user.create(\n+ username="foo1234",\n+ email="foo@bar.com",\n+ roles=["Manager"],\n+ properties={"fullname": "Foo Bar"},\n+ )\n+ pas = api.portal.get_tool("acl_users")\n+ # generally the username and userid are the same...\n+ self.assertEqual(pas.getUserById("foo1234").getUserName(), "foo1234")\n+ # ...but we can change it\n+ pas.updateLoginName("foo1234", "foo")\n+ self.assertEqual(pas.getUserById("foo1234").getUserName(), "foo")\n+ with api.env.adopt_user(username="foo"):\n+ lockable.lock()\n+ transaction.commit()\n+ response = self.api_session.get("/@lock")\n+ self.assertEqual(response.status_code, 200)\n+ # here the userid\n+ self.assertEqual(response.json()["creator"], "foo1234")\n+ self.assertEqual(response.json()["creator_name"], "Foo Bar")\n+ self.assertTrue(lockable.locked())\n' | ||
b'diff --git a/README.md b/README.md\nindex 72ee071..576390d 100644\n--- a/README.md\n+++ b/README.md\n@@ -293,11 +293,14 @@ Folder containing JSON data representing this distribution\'s content.\n To export content from a site into this folder, use the `bin/export-distribution` script.\n \n ```shell\n-bin/export-distribution path/to/zope.conf Plone\n+bin/export-distribution [--include-revisions] path/to/zope.conf Plone\n ```\n \n > In the example above, "Plone" is the ID of the Plone site to export.\n \n+By default, the revisions history (older versions of each content item) are not exported.\n+If you do want them, add `--include-revisions` on the command line.\n+\n ## Advanced Usage\n \n ### Hiding Distributions\ndiff --git a/news/39.feature b/news/39.feature\nnew file mode 100644\nindex 0000000..0c2a4f6\n--- /dev/null\n+++ b/news/39.feature\n@@ -0,0 +1 @@\n+Include revisions only when passing `--include-revisions`. @mauritsvanrees\ndiff --git a/setup.py b/setup.py\nindex 247f835..6158741 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -55,7 +55,7 @@\n "plone.api",\n "plone.base",\n "plone.dexterity",\n- "plone.exportimport>=1.0.0a5",\n+ "plone.exportimport>=1.0.0b1",\n "plone.i18n",\n "plone.protect",\n "plone.rest",\ndiff --git a/src/plone/distribution/cli/__init__.py b/src/plone/distribution/cli/__init__.py\nindex 4ab63d6..208f4a5 100644\n--- a/src/plone/distribution/cli/__init__.py\n+++ b/src/plone/distribution/cli/__init__.py\n@@ -13,6 +13,7 @@\n "options": {\n "zopeconf": "Path to zope.conf",\n "site": "Plone site ID to export the content from",\n+ "--include-revisions": "Include revision history",\n },\n },\n }\n@@ -21,7 +22,10 @@\n def _parse_args(description: str, options: dict, args: list):\n parser = argparse.ArgumentParser(description=description)\n for key, help in options.items():\n- parser.add_argument(key, help=help)\n+ if key.startswith("-"):\n+ parser.add_argument(key, action="store_true", help=help)\n+ else:\n+ parser.add_argument(key, help=help)\n namespace, _ = parser.parse_known_args(args[1:])\n return namespace\n \n@@ -30,6 +34,7 @@ def export(args=sys.argv):\n """Export a Plone site to a distribution."""\n logger = cli_helpers.get_logger("Exporter")\n exporter_cli = CLI_SPEC["exporter"]\n+ # We get an argparse.Namespace instance.\n namespace = _parse_args(exporter_cli["description"], exporter_cli["options"], args)\n app = cli_helpers.get_app(namespace.zopeconf)\n site = cli_helpers.get_site(app, namespace.site, logger)\n@@ -41,6 +46,6 @@ def export(args=sys.argv):\n logger.info(f"Exporting Plone site at /{site.id}")\n logger.info(f" Target path: {path}")\n with api.env.adopt_roles(["Manager"]):\n- results = get_exporter(site).export_site(path)\n+ results = get_exporter(site).export_site(path, options=namespace)\n for item in results[1:]:\n logger.info(f" Wrote {item.relative_to(path)}")\n' | ||
|