Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #55 from plone/no-zcml
Browse files Browse the repository at this point in the history
No more zcml in core
  • Loading branch information
bloodbare committed Jan 25, 2017
2 parents ab6e6a2 + 69eac3e commit 0b93bae
Show file tree
Hide file tree
Showing 37 changed files with 194 additions and 278 deletions.
22 changes: 22 additions & 0 deletions ZOPE_FUTURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Throwing this out there...

Zope has connotations and cognitive overhead for people to think about.

Long term, we'd like to fork/simply all zope dependencies.

The component architecture, interfaces and security is amazing software; however,
for simplification and longterm success of project, we'd like to pull whatever we can out.


Package candidates:

- zope.component
- zope.configuration
- zope.interface
- zope.lifecycleevent
- zope.schema
- zope.event


Basically... anything where a user would be make imports for packages,
we want those imports to be part of THIS package.
9 changes: 9 additions & 0 deletions docs/source/applicationconfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ to those decorators.
* _provides_: Interface this adapter provides--must be used along with factory


## utility

*`@configure.utility`*

* _provides_: Interface this utility provides
* _name_: Name of utility
* _factory_: A factory used to create the subscriber instance


## permission

*`configure.permission`*
Expand Down
3 changes: 3 additions & 0 deletions src/plone.server/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ New features:
with decorators, not zcml
[vangheem]

- No more zcml in core
[vangheem]


1.0a9 (2017-01-18)
------------------
Expand Down
4 changes: 2 additions & 2 deletions src/plone.server/plone/server/api/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DefaultPOST(Service):

async def __call__(self):
"""To create a content."""
data = await self.request.json()
data = await self.get_data()
type_ = data.get('@type', None)
id_ = data.get('id', None)
behaviors = data.get('@behaviors', None)
Expand Down Expand Up @@ -142,7 +142,7 @@ class DefaultPUT(Service):
@configure.service(context=IResource, method='PATCH', permission='plone.ModifyContent')
class DefaultPATCH(Service):
async def __call__(self):
data = await self.request.json()
data = await self.get_data()
behaviors = data.get('@behaviors', None)
for behavior in behaviors or ():
self.context.add_behavior(behavior)
Expand Down
3 changes: 2 additions & 1 deletion src/plone.server/plone/server/api/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@


class Service(View):
pass
async def get_data(self):
return await self.request.json()


class DownloadService(View):
Expand Down
18 changes: 0 additions & 18 deletions src/plone.server/plone/server/auth/configure.zcml

This file was deleted.

8 changes: 4 additions & 4 deletions src/plone.server/plone/server/auth/participation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from plone.server import configure
from plone.server.auth import authenticate_request
from plone.server.auth.groups import PloneGroup
from plone.server.auth.users import AnonymousUser
from plone.server.interfaces import IRequest
from plone.server.transactions import get_current_request
from zope.component import adapter
from zope.interface import implementer
from zope.authentication.interfaces import IAuthentication
from zope.security.interfaces import IParticipation


Expand All @@ -17,8 +17,7 @@ def __init__(self, request):
self.interaction = None


@adapter(IRequest)
@implementer(IParticipation)
@configure.adapter(for_=IRequest, provides=IParticipation)
class PloneParticipation(object):
principal = None

Expand All @@ -40,6 +39,7 @@ async def __call__(self):
self.interaction = None


@configure.utility(provides=IAuthentication)
class ZopeAuthentication(object):
""" Class used to get groups. """

Expand Down
8 changes: 6 additions & 2 deletions src/plone.server/plone/server/auth/principalrole.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"""Mappings between principals and roles, stored in an object locally."""
from zope.interface import implementer
from plone.server import configure
from plone.server.interfaces import IResource
from zope.securitypolicy.interfaces import IPrincipalRoleManager
from zope.securitypolicy.principalrole import AnnotationPrincipalRoleManager
from zope.securitypolicy.securitymap import AnnotationSecurityMap


@implementer(IPrincipalRoleManager)
@configure.adapter(
for_=IResource,
provides=IPrincipalRoleManager,
trusted=True)
class AnnotationPlonePrincipalRoleManager(AnnotationPrincipalRoleManager):
"""Mappings between principals and roles with global."""

Expand Down
31 changes: 0 additions & 31 deletions src/plone.server/plone/server/basicfile.zcml

This file was deleted.

13 changes: 8 additions & 5 deletions src/plone.server/plone/server/browser.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
from plone.server import configure
from plone.server.interfaces import IAbsoluteURL
from plone.server.interfaces import ISerializableException
from plone.server.interfaces import IRequest
from plone.server.interfaces import IResource
from plone.server.interfaces import ISerializableException
from plone.server.interfaces import IView
from plone.server.transactions import get_current_request
from zope.component import adapter
Expand Down Expand Up @@ -48,8 +49,9 @@ async def __call__(self):
}


@adapter(IResource, IRequest)
@implementer(IAbsoluteURL)
@configure.adapter(
for_=(IResource, IRequest),
provides=IAbsoluteURL)
class Absolute_URL(object):

def __init__(self, context, request):
Expand Down Expand Up @@ -81,8 +83,9 @@ def __call__(self, relative=False, site_url=False):
self.request._db_id + path


@adapter(IResource)
@implementer(IAbsoluteURL)
@configure.adapter(
for_=IResource,
provides=IAbsoluteURL)
class Absolute_URL_ObtainRequest(Absolute_URL):

def __init__(self, context):
Expand Down
6 changes: 5 additions & 1 deletion src/plone.server/plone/server/catalog/catalog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from plone.server import configure
from plone.server.catalog import NoIndexField
from plone.server.content import iter_schemata_for_type
from plone.server.directives import index
Expand All @@ -7,6 +8,7 @@
from plone.server.directives import metadata
from plone.server.interfaces import ICatalogDataAdapter
from plone.server.interfaces import ICatalogUtility
from plone.server.interfaces import IResource
from plone.server.json.serialize_value import json_compatible
from zope.component import queryAdapter
from zope.interface import implementer
Expand Down Expand Up @@ -74,7 +76,9 @@ def get_data(self, content):
return data


@implementer(ICatalogDataAdapter)
@configure.adapter(
for_=IResource,
provides=ICatalogDataAdapter)
class DefaultCatalogDataAdapter(object):

def __init__(self, content):
Expand Down
42 changes: 0 additions & 42 deletions src/plone.server/plone/server/catalog/configure.zcml

This file was deleted.

12 changes: 12 additions & 0 deletions src/plone.server/plone/server/catalog/index.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# -*- coding: utf-8 -*-
from plone.server import configure
from plone.server.interfaces import ICatalogUtility
from plone.server.interfaces import IObjectFinallyCreatedEvent
from plone.server.interfaces import IObjectFinallyDeletedEvent
from plone.server.interfaces import IObjectFinallyModifiedEvent
from plone.server.interfaces import IResource
from plone.server.interfaces import ISite
from plone.server.transactions import get_current_request
from plone.server.transactions import RequestNotFound
from plone.server.transactions import tm
from zope.component import queryUtility
from zope.lifecycleevent.interfaces import IObjectAddedEvent
from zope.lifecycleevent.interfaces import IObjectRemovedEvent

import transaction

Expand Down Expand Up @@ -57,6 +64,7 @@ def get_hook():
return hook


@configure.subscriber(for_=(IResource, IObjectFinallyDeletedEvent))
def remove_object(obj, event):
uid = getattr(obj, 'uuid', None)
if uid is None:
Expand All @@ -73,6 +81,8 @@ def remove_object(obj, event):
del hook.index[uid]


@configure.subscriber(for_=(IResource, IObjectFinallyCreatedEvent))
@configure.subscriber(for_=(IResource, IObjectFinallyModifiedEvent))
def add_object(obj, event):
uid = getattr(obj, 'uuid', None)
if uid is None:
Expand All @@ -89,12 +99,14 @@ def add_object(obj, event):
hook.index[uid] = search.get_data(obj)


@configure.subscriber(for_=(ISite, IObjectAddedEvent))
async def initialize_catalog(site, event):
search = queryUtility(ICatalogUtility)
if search:
await search.initialize_catalog(site)


@configure.subscriber(for_=(ISite, IObjectRemovedEvent))
async def remove_catalog(site, event):
search = queryUtility(ICatalogUtility)
if search:
Expand Down
7 changes: 4 additions & 3 deletions src/plone.server/plone/server/commands/migrate.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from plone.server import app_settings
from plone.server import migrate
from plone.server.commands import Command
from plone.server.interfaces import IApplication
from plone.server.interfaces import IDatabase
from plone.server.interfaces import MIGRATION_DATA_REGISTRY_KEY
from plone.server.testing import TESTING_SETTINGS
from zope.component import getUtility
from plone.server.interfaces import IApplication


def traverse_to_path(app, path):
Expand Down Expand Up @@ -39,7 +40,7 @@ def report(self, arguments, sites, apps):
db, site = data
registry = site['_registry']
try:
installed_versions = registry['_migrations_info']
installed_versions = registry[MIGRATION_DATA_REGISTRY_KEY]
except KeyError:
installed_versions = {}
title = '{} Migrations'.format(site_path)
Expand Down Expand Up @@ -111,7 +112,7 @@ def run(self, arguments, settings, app):
for app in apps:
registry = site['_registry']
try:
installed_versions = registry['_migrations_info']
installed_versions = registry[MIGRATION_DATA_REGISTRY_KEY]
except KeyError:
installed_versions = {}
_migrations = migrate.get_migrations(
Expand Down

0 comments on commit 0b93bae

Please sign in to comment.