Skip to content

Commit

Permalink
WCM-285: remove the development columns from the standard dav converter
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
stollero committed Sep 18, 2024
1 parent 6300fac commit 57f634f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
1 change: 1 addition & 0 deletions core/docs/changelog/WCM-285.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WCM-285: remove the development columns from the standard dav converter
7 changes: 1 addition & 6 deletions core/src/zeit/cms/content/dav.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -327,20 +327,15 @@ 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
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
Expand Down
2 changes: 1 addition & 1 deletion core/src/zeit/connector/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions core/src/zeit/connector/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'
4 changes: 2 additions & 2 deletions core/src/zeit/connector/tests/test_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand Down

0 comments on commit 57f634f

Please sign in to comment.