Skip to content

Commit

Permalink
Fixed false implemented Factories and Markers for ILeadImage and IRic…
Browse files Browse the repository at this point in the history
…hText.
  • Loading branch information
iham committed Jul 6, 2018
1 parent e36df79 commit 72fe89c
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 27 deletions.
27 changes: 24 additions & 3 deletions CHANGES.rst
Expand Up @@ -6,15 +6,36 @@ Changelog

Breaking changes:

- *add item here*
- ILeadImage and IRichText behaviors now have proper "Marker"-Interfaces.
This might break code in other places as
ILeadImage.providedBy(<obj>) -> False
ILeadImageMarker.providedBy(<obj>) -> True
IRichText(<obj>).providedBy(<obj>) -> False
IRichTextMarker.providedBy(<obj>) -> True
[iham]

New features:

- *add item here*
- By using correct (Marker-)Interfaces for the ILeadImage and IRichText,
the factories are now working properly and can be reconfigured
wherever you might need them. ZCA FTW!
[iham]

Bug fixes:

- *add item here*
- Fixed false implemented Factories and Markers for ILeadImage and IRichText.
see `issue 457 <https://github.com/plone/plone.app.contenttypes/issues/476>`
[iham]

- Fixed Tests for collection and migration.
see `issue <https://github.com/plone/plone.app.contenttypes/issues/477>`
[iham]

- Pinned pydocstyle as it broke buildout.
[iham]

- pep8 cleanup.
[iham]


1.4.11 (2018-06-18)
Expand Down
3 changes: 2 additions & 1 deletion buildout.cfg
Expand Up @@ -2,7 +2,7 @@
extends = http://dist.plone.org/release/5.1-latest/versions.cfg
extensions = mr.developer
package-name = plone.app.contenttypes
package-extras = [test]
package-extras = [test, archetypes]
parts =
instance
test
Expand Down Expand Up @@ -91,3 +91,4 @@ robotframework-selenium2library = 1.6.0
robotsuite = 1.6.1
selenium = 2.46.0
coverage = 3.7.1
pycodestyle = 2.3.1
8 changes: 4 additions & 4 deletions plone/app/contenttypes/behaviors/configure.zcml
Expand Up @@ -14,12 +14,12 @@
provides=".leadimage.ILeadImage"
factory=".leadimage.LeadImage"
for="plone.dexterity.interfaces.IDexterityContent"
marker=".leadimage.ILeadImage"
marker=".leadimage.ILeadImageMarker"
/>

<browser:viewlet
name="contentleadimage"
for=".leadimage.ILeadImage"
for=".leadimage.ILeadImageMarker"
view="plone.app.layout.globals.interfaces.IViewView"
class=".viewlets.LeadImageViewlet"
manager="plone.app.layout.viewlets.interfaces.IAboveContentTitle"
Expand Down Expand Up @@ -52,7 +52,7 @@
provides=".richtext.IRichText"
factory=".richtext.RichText"
for="plone.dexterity.interfaces.IDexterityContent"
marker=".richtext.IRichText"
marker=".richtext.IRichTextMarker"
/>

<plone:behavior
Expand All @@ -64,7 +64,7 @@

<browser:page
name="getText"
for=".richtext.IRichText"
for=".richtext.IRichTextMarker"
class=".richtext.WidgetView"
permission="zope2.View"
template="richtext_gettext.pt"
Expand Down
21 changes: 21 additions & 0 deletions plone/app/contenttypes/behaviors/leadimage.py
Expand Up @@ -8,6 +8,11 @@
from zope.component import adapter
from zope.interface import implementer
from zope.interface import provider
from zope.interface import Interface


class ILeadImageMarker(Interface):
pass


@provider(IFormFieldProvider)
Expand All @@ -32,3 +37,19 @@ class LeadImage(object):

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

@property
def image(self):
return self.context.image

@image.setter
def image(self, value):
self.context.image = value

@property
def image_caption(self):
return self.context.image_caption

@image_caption.setter
def image_caption(self, value):
self.context.image_caption = value
13 changes: 13 additions & 0 deletions plone/app/contenttypes/behaviors/richtext.py
Expand Up @@ -9,9 +9,14 @@
from plone.supermodel import model
from zope.component import adapter
from zope.interface import implementer
from zope.interface import Interface
from zope.interface import provider


class IRichTextMarker(Interface):
pass


@provider(IFormFieldProvider)
class IRichText(model.Schema):

Expand All @@ -31,6 +36,14 @@ class RichText(object):
def __init__(self, context):
self.context = context

@property
def text(self):
return self.context.text

@text.setter
def text(self, value):
self.context.text = value


class WidgetView(WidgetsView):
schema = IRichText
4 changes: 2 additions & 2 deletions plone/app/contenttypes/behaviors/viewlets.py
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from plone.app.contenttypes.behaviors.leadimage import ILeadImage
from plone.app.contenttypes.behaviors.leadimage import ILeadImageMarker
from plone.app.layout.viewlets import ViewletBase


class LeadImageViewlet(ViewletBase):
""" A simple viewlet which renders leadimage """

def update(self):
self.context = ILeadImage(self.context)
self.context = ILeadImageMarker(self.context)
self.available = True if self.context.image else False
8 changes: 3 additions & 5 deletions plone/app/contenttypes/testing.py
Expand Up @@ -15,7 +15,6 @@
from zope.interface import alsoProvides

import pkg_resources
import unittest


def set_browserlayer(request):
Expand Down Expand Up @@ -66,11 +65,11 @@ def tearDownPloneSite(self, portal):


try:
pkg_resources.get_distribution('Products.ATContentTypes')
import Products.ATContentTypes
except ImportError:
TEST_MIGRATION = False
else:
TEST_MIGRATION = True
except pkg_resources.DistributionNotFound:
TEST_MIGRATION = False


class PloneAppContenttypesMigration(PloneSandboxLayer):
Expand All @@ -85,7 +84,6 @@ def setUpZope(self, app, configurationContext):
return

# prepare installing Products.ATContentTypes
import Products.ATContentTypes
self.loadZCML(package=Products.ATContentTypes)
z2.installProduct(app, 'Products.Archetypes')
z2.installProduct(app, 'Products.ATContentTypes')
Expand Down
18 changes: 13 additions & 5 deletions plone/app/contenttypes/tests/test_collection.py
Expand Up @@ -396,11 +396,19 @@ def test_respect_navigation_root(self):
title='Collection 1')
collection1 = folder1['collection1']
wrapped = ICollection_behavior(collection1)
wrapped.query = [{
'i': 'portal_type',
'o': 'plone.app.querystring.operation.string.is',
'v': 'Document',
}]
wrapped.query = [
{
'i': 'portal_type',
'o': 'plone.app.querystring.operation.string.is',
'v': 'Document',
},
# use a "/" path and navroot works fine!
{
'i': 'path',
'o': 'plone.app.querystring.operation.string.path',
'v': '/',
},
]

# Check if only the item inside folder1 is returned, since it's a
# navigation root.
Expand Down
2 changes: 1 addition & 1 deletion plone/app/contenttypes/tests/test_content_profile.py
Expand Up @@ -93,7 +93,7 @@ def test_Members_portlets(self):
self.assertTrue(assignable_manager.getBlacklistStatus('context'))
self.assertTrue(assignable_manager.getBlacklistStatus('group'))
self.assertTrue(assignable_manager.getBlacklistStatus('content_type'))

def test_Members_is_private(self):
# Is the content object public?
obj = self.portal['Members']
Expand Down
3 changes: 2 additions & 1 deletion plone/app/contenttypes/tests/test_image.py
Expand Up @@ -112,9 +112,10 @@ def test_svg_image(self):
scale = self.image.restrictedTraverse('@@images')
self.assertRegexpMatches(
scale.scale('image', scale='large').tag(),
r'<img src="http://nohost/plone/image/@@images/[a-z0-9--]*.svg" alt="My Image" title="My Image" height="768" width="768" />'
r'<img src="http://nohost/plone/image/@@images/[a-z0-9--]*.svg" alt="My Image" title="My Image" height="768" width="768" />' # noqa E501
)


class ImageFunctionalTest(unittest.TestCase):

layer = PLONE_APP_CONTENTTYPES_FUNCTIONAL_TESTING
Expand Down
4 changes: 3 additions & 1 deletion plone/app/contenttypes/tests/test_link.py
Expand Up @@ -173,7 +173,9 @@ def test_link_redirect_view_path_with_variable_and_parameters(self):
# As anonymous: redirect
logout()
self.assertTrue(view())
self._assert_redirect('http://nohost/plone/@@search?SearchableText=Plone')
self._assert_redirect(
'http://nohost/plone/@@search?SearchableText=Plone',
)

def test_mailto_type(self):
self.link.remoteUrl = 'mailto:stress@test.us'
Expand Down
6 changes: 3 additions & 3 deletions plone/app/contenttypes/tests/test_migration_custom.py
Expand Up @@ -7,9 +7,9 @@

if TEST_MIGRATION:
from datetime import datetime
from plone.app.contenttypes.migration.field_migrators import migrate_filefield
from plone.app.contenttypes.migration.field_migrators import migrate_imagefield
from plone.app.contenttypes.migration.field_migrators import migrate_simplefield # noqa
from plone.app.contenttypes.migration.field_migrators import migrate_filefield # noqa E501
from plone.app.contenttypes.migration.field_migrators import migrate_imagefield # noqa E501
from plone.app.contenttypes.migration.field_migrators import migrate_simplefield # noqa E501
from plone.app.contenttypes.migration.utils import installTypeIfNeeded
from plone.app.testing import applyProfile
from plone.app.testing import login
Expand Down
1 change: 0 additions & 1 deletion plone/app/contenttypes/tests/test_migration_topic.py
Expand Up @@ -16,7 +16,6 @@
from zope.component import queryUtility
from zope.interface import implementer


@implementer(ICollection)
class FolderishCollection(Container):
"""Test subclass for folderish ``Collections``.
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Expand Up @@ -11,10 +11,12 @@
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()


long_description = \
read('README.rst') + '\n\n' + \
read('CHANGES.rst')


setup(name='plone.app.contenttypes',
version=version,
description="Default content types for Plone based on Dexterity",
Expand Down

0 comments on commit 72fe89c

Please sign in to comment.