Skip to content

Commit

Permalink
fixes #34: zope.interface 4.7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Feb 12, 2020
1 parent 5f53d23 commit 16765d3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions news/34.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support for zope.interface 4.7+ [jensens]
15 changes: 12 additions & 3 deletions plone/supermodel/directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from zope.component import adapter
from zope.interface import alsoProvides
from zope.interface import implementer
from zope.interface.interface import Element
from zope.interface.interface import TAGGED_DATA

import os.path
Expand Down Expand Up @@ -71,7 +72,7 @@ class CheckerPlugin(object):

def __init__(self, schema):
self.schema = schema
self.value = schema.queryTaggedValue(self.key, None)
self.value = Element.queryTaggedValue(schema, self.key, default=None)

def fieldNames(self):
raise NotImplementedError()
Expand Down Expand Up @@ -148,10 +149,18 @@ def __init__(self, interface):

def __call__(self):
interface = self.interface
filename = interface.queryTaggedValue(FILENAME_KEY, None)
filename = Element.queryTaggedValue(
interface,
FILENAME_KEY,
default=None,
)
if filename is None:
return
schema = interface.queryTaggedValue(SCHEMA_NAME_KEY, u'')
schema = Element.queryTaggedValue(
interface,
SCHEMA_NAME_KEY,
default=u'',
)

moduleName = interface.__module__
module = sys.modules.get(moduleName, None)
Expand Down
12 changes: 4 additions & 8 deletions plone/supermodel/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from collections import OrderedDict
from lxml import etree
from plone.supermodel.debug import parseinfo
from plone.supermodel.interfaces import I18N_NAMESPACE
Expand All @@ -8,6 +9,7 @@
from zope.i18nmessageid import Message
from zope.interface import directlyProvidedBy
from zope.interface import directlyProvides
from zope.interface.interface import Element
from zope.schema.interfaces import IChoice
from zope.schema.interfaces import ICollection
from zope.schema.interfaces import IDict
Expand All @@ -21,12 +23,6 @@
import sys


try:
from collections import OrderedDict
except ImportError:
from zope.schema.vocabulary import OrderedDict # <py27


_marker = object()
noNS_re = re.compile('^{\S+}')

Expand Down Expand Up @@ -269,7 +265,7 @@ def mergedTaggedValueDict(schema, name):
"""
tv = {}
for iface in reversed(schema.__iro__):
tv.update(iface.queryTaggedValue(name, {}))
tv.update(Element.queryTaggedValue(iface, name, default={}))
return tv


Expand All @@ -281,7 +277,7 @@ def mergedTaggedValueList(schema, name):
"""
tv = []
for iface in reversed(schema.__iro__):
tv.extend(iface.queryTaggedValue(name, []))
tv.extend(Element.queryTaggedValue(iface, name, default=[]))
return tv


Expand Down

0 comments on commit 16765d3

Please sign in to comment.