From 57f634f425d19650a5aa48315c633b2674940ede Mon Sep 17 00:00:00 2001 From: Martin Stolle Date: Wed, 18 Sep 2024 13:53:32 +0200 Subject: [PATCH] WCM-285: remove the development columns from the standard dav converter - also updated the properties contract (again), contract is, leave dav as dav property and internally convert to correct type - later we want to remove the dav type from the formula and only read from database so that bool can stay bool and if this is the case, we can bring back to Code from the IDAVPropertyConverter --- core/docs/changelog/WCM-285.change | 1 + core/src/zeit/cms/content/dav.py | 7 +------ core/src/zeit/connector/mock.py | 2 +- core/src/zeit/connector/models.py | 4 ++-- core/src/zeit/connector/tests/test_contract.py | 4 ++-- 5 files changed, 7 insertions(+), 11 deletions(-) create mode 100644 core/docs/changelog/WCM-285.change diff --git a/core/docs/changelog/WCM-285.change b/core/docs/changelog/WCM-285.change new file mode 100644 index 0000000000..5fa6c015c1 --- /dev/null +++ b/core/docs/changelog/WCM-285.change @@ -0,0 +1 @@ +WCM-285: remove the development columns from the standard dav converter diff --git a/core/src/zeit/cms/content/dav.py b/core/src/zeit/cms/content/dav.py index 79fbf84886..e882cfcb24 100644 --- a/core/src/zeit/cms/content/dav.py +++ b/core/src/zeit/cms/content/dav.py @@ -16,7 +16,7 @@ from zeit.cms.content.interfaces import WRITEABLE_ON_CHECKIN from zeit.cms.content.sources import FEATURE_TOGGLES -from zeit.connector.models import ContentWithMetadataColumns as ConnectorModel +from zeit.connector.models import Content as ConnectorModel from zeit.connector.resource import PropertyKey import zeit.cms.content.caching import zeit.cms.content.interfaces @@ -327,11 +327,8 @@ def toProperty(self, value): class BoolProperty: def __init__(self, context, properties, propertykey): self.context = context - self.has_sql_type = ConnectorModel.column_by_name(*propertykey) is not None def fromProperty(self, value): - if self.has_sql_type and FEATURE_TOGGLES.find('read_metadata_columns'): - return value return self._fromProperty(value) @staticmethod @@ -339,8 +336,6 @@ def _fromProperty(value): return value.lower() in ('yes', 'true') def toProperty(self, value): - if self.has_sql_type and FEATURE_TOGGLES.find('write_metadata_columns'): - return value return self._toProperty(value) @staticmethod diff --git a/core/src/zeit/connector/mock.py b/core/src/zeit/connector/mock.py index 728eca83d3..a73d2a2145 100644 --- a/core/src/zeit/connector/mock.py +++ b/core/src/zeit/connector/mock.py @@ -24,7 +24,7 @@ MoveError, ) from zeit.connector.lock import lock_is_foreign -from zeit.connector.models import ContentWithMetadataColumns as Content +from zeit.connector.models import DevelopmentContent as Content import zeit.cms.config import zeit.cms.repository.interfaces import zeit.connector.cache diff --git a/core/src/zeit/connector/models.py b/core/src/zeit/connector/models.py index b0dc8ab769..bd60db7f2f 100644 --- a/core/src/zeit/connector/models.py +++ b/core/src/zeit/connector/models.py @@ -306,7 +306,7 @@ class DevelopmentBase(sqlalchemy.orm.DeclarativeBase): """Experimental development features, not ready for any deployment or migration!""" -class ContentWithMetadataColumns( +class DevelopmentContent( DevelopmentBase, ContentBase, CommonMetadata, @@ -322,4 +322,4 @@ class ContentWithMetadataColumns( # Having to duplicate all classes (and add indirections to their `relationship()`s) # is annoying, but there's no obvious way around it. class LockWithMetadataColumns(DevelopmentBase, LockBase): - content_class = 'ContentWithMetadataColumns' + content_class = 'DevelopmentContent' diff --git a/core/src/zeit/connector/tests/test_contract.py b/core/src/zeit/connector/tests/test_contract.py index 94200170c9..b896d2a57d 100644 --- a/core/src/zeit/connector/tests/test_contract.py +++ b/core/src/zeit/connector/tests/test_contract.py @@ -898,11 +898,11 @@ def test_converts_scalar_types_on_read(self): 'http://xml.zeit.de/testcontent', {('overscrolling', 'http://namespaces.zeit.de/CMS/document'): 'yes'}, ) - self.assertIs('yes', self.repository['testcontent'].overscrolling) + self.assertIs(True, self.repository['testcontent'].overscrolling) def test_converts_scalar_types_on_write(self): with checked_out(self.repository['testcontent']) as co: - co.overscrolling = 'yes' + co.overscrolling = True resource = self.repository.connector['http://xml.zeit.de/testcontent'] self.assertIs( 'yes', resource.properties[('overscrolling', 'http://namespaces.zeit.de/CMS/document')]