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 #60 from plone/factory-reorg
Browse files Browse the repository at this point in the history
reorganize factory module
  • Loading branch information
vangheem committed Jan 30, 2017
2 parents a599c4c + 678434f commit 69ad89b
Show file tree
Hide file tree
Showing 13 changed files with 630 additions and 552 deletions.
5 changes: 3 additions & 2 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ eggs =

[gunicorn]
recipe = zc.recipe.egg
eggs =
eggs =
gunicorn
uvloop
plone.server
Expand Down Expand Up @@ -90,6 +90,7 @@ eggs =
plone.server [test]
plone.example


[versions]
pycodestyle = 2.2.0

flake8 = 3.2.1
4 changes: 4 additions & 0 deletions src/plone.server/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

New features:

- be able provide your own database factories by providing named utilities for
the IDatabaseConfigurationFactory interface
[vangheem]

- install, uninstall methods for addon class can now be async
[vangheem]

Expand Down
14 changes: 13 additions & 1 deletion src/plone.server/plone/server/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,19 @@ def load_subscriber(_context, subscriber):

def load_utility(_context, _utility):
conf = _utility['config']
conf['factory'] = resolve_or_get(conf.get('factory') or _utility['klass'])
if 'factory' in conf:
conf['factory'] = resolve_or_get(conf['factory'])
elif 'component' in conf:
conf['component'] = resolve_or_get(conf['component'])
else:
# use provided klass
klass = _utility['klass']
if isinstance(klass, type):
# is a class type, use factory setting
conf['factory'] = klass
else:
# not a factory
conf['component'] = klass
zcml.utility(
_context,
**conf
Expand Down

0 comments on commit 69ad89b

Please sign in to comment.