Skip to content

Commit

Permalink
Merge pull request #42 from plone/gforcada-remove-formlib
Browse files Browse the repository at this point in the history
Remove zope.formlib dependency
  • Loading branch information
gforcada committed Oct 18, 2016
2 parents 8a95f7e + 32a4264 commit 53c193b
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ Changelog

Breaking changes:

- *add item here*
- Make zope.formlib optional.
[gforcada]

- Mark vocabularies based on zope.formlib as deprecated.
[gforcada]

New features:

Expand Down
14 changes: 13 additions & 1 deletion plone/app/vocabularies/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from Products.ZCTextIndex.ParseTree import ParseError
from zope.browser.interfaces import ITerms
from zope.component import queryUtility
from zope.formlib.interfaces import ISourceQueryView
from zope.interface import implementer
from zope.interface import provider
from zope.schema.interfaces import IContextSourceBinder
Expand All @@ -26,6 +25,16 @@

import itertools
import os
import warnings


try:
from zope.formlib.interfaces import ISourceQueryView
except ImportError:
from zope.interface import Interface

class ISourceQueryView(Interface):
pass


def parse_query(query, path_prefix=''):
Expand Down Expand Up @@ -317,6 +326,9 @@ class QuerySearchableTextSourceView(object):
template = ViewPageTemplateFile('searchabletextsource.pt')

def __init__(self, context, request):
msg = 'QuerySearchableTextSourceView is deprecated and will be ' \
'removed on Plone 6'
warnings.warn(msg, DeprecationWarning)
self.context = context
self.request = request

Expand Down
3 changes: 3 additions & 0 deletions plone/app/vocabularies/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
/>

<adapter
zcml:condition="installed zope.formlib"
for=".catalog.SearchableTextSource
zope.publisher.interfaces.browser.IBrowserRequest"
factory=".catalog.QuerySearchableTextSourceView"
Expand All @@ -182,6 +183,7 @@
/>

<adapter
zcml:condition="installed zope.formlib"
for=".users.UsersSource
zope.publisher.interfaces.browser.IBrowserRequest"
factory=".users.UsersSourceQueryView"
Expand All @@ -196,6 +198,7 @@
/>

<adapter
zcml:condition="installed zope.formlib"
for=".groups.GroupsSource
zope.publisher.interfaces.browser.IBrowserRequest"
factory=".groups.GroupsSourceQueryView"
Expand Down
15 changes: 14 additions & 1 deletion plone/app/vocabularies/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@
from Products.CMFCore.utils import getToolByName
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from zope.browser.interfaces import ITerms
from zope.formlib.interfaces import ISourceQueryView
from zope.interface import implementer
from zope.interface import provider
from zope.schema.interfaces import IContextSourceBinder
from zope.schema.interfaces import ISource
from zope.schema.vocabulary import SimpleTerm

import warnings


try:
from zope.formlib.interfaces import ISourceQueryView
except ImportError:
from zope.interface import Interface

class ISourceQueryView(Interface):
pass


@implementer(ISource)
@provider(IContextSourceBinder)
Expand Down Expand Up @@ -137,6 +147,9 @@ class GroupsSourceQueryView(object):
template = ViewPageTemplateFile('searchabletextsource.pt')

def __init__(self, context, request):
msg = 'GroupsSourceQueryView is deprecated and will be removed on ' \
'Plone 6'
warnings.warn(msg, DeprecationWarning)
self.context = context
self.request = request

Expand Down
15 changes: 14 additions & 1 deletion plone/app/vocabularies/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from zope.browser.interfaces import ITerms
from zope.component.hooks import getSite
from zope.formlib.interfaces import ISourceQueryView
from zope.interface import implementer
from zope.interface import provider
from zope.schema.interfaces import IContextSourceBinder
from zope.schema.interfaces import ISource
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.vocabulary import SimpleTerm

import warnings


try:
from zope.formlib.interfaces import ISourceQueryView
except ImportError:
from zope.interface import Interface

class ISourceQueryView(Interface):
pass


def _createUserTerm(userid, context=None, acl_users=None):
if acl_users is None:
Expand Down Expand Up @@ -184,6 +194,9 @@ class UsersSourceQueryView(object):
template = ViewPageTemplateFile('searchabletextsource.pt')

def __init__(self, context, request):
msg = 'UsersSourceQueryView is deprecated and will be removed on ' \
'Plone 6'
warnings.warn(msg, DeprecationWarning)
self.context = context
self.request = request

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
'setuptools',
'zope.browser',
'zope.component',
'zope.formlib',
'zope.i18n',
'zope.i18nmessageid',
'zope.interface',
Expand Down

1 comment on commit 53c193b

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gforcada Jenkins CI reporting about code analysis
See the full report here: http://jenkins.plone.org/job/package-plone.app.vocabularies/25/violations

plone/app/vocabularies/__init__.py:3:28: D001 found directlyProvides replace it with zope.interface.provider
plone/app/vocabularies/__init__.py:20:13: D001 found directlyProvides replace it with zope.interface.provider

Follow these instructions to reproduce it locally.

Please sign in to comment.