# HG changeset patch # User Damien Correia # Date 1527260803 -7200 # Node ID 931959214ed9cd3bad14e7cb8e6d6012acba9714 # Parent 86d0f27c7f46e869a7808e60dd9a281d13f5d75c# Parent b713404fd6e5dc79731b2c64463c799c3baa8916 merge default diff -r 86d0f27c7f46 -r 931959214ed9 src/pyams_utils/adapter.py --- a/src/pyams_utils/adapter.py Fri May 25 15:21:23 2018 +0200 +++ b/src/pyams_utils/adapter.py Fri May 25 17:06:43 2018 +0200 @@ -131,14 +131,14 @@ return wrapped -def get_annotation_adapter(context, key, factory, markers=None, notify=True, +def get_annotation_adapter(context, key, factory=None, markers=None, notify=True, locate=True, parent=None, name=None): """Get an adapter via object's annotations, creating it if not existent :param object context: context object which should be adapted :param str key: annotations key to look for :param factory: if annotations key is not found, this is the factory which will be used to - create a new object + create a new object; if factory is None and is requested object can't be found, None is returned :param markers: if not None, list of marker interfaces which created adapter should provide :param bool=True notify: if 'False', no notification event will be sent on object creation :param bool=True locate: if 'False', the new object is not attached to any parent @@ -151,6 +151,8 @@ return None adapter = annotations.get(key) if adapter is None: + if factory is None: + return None adapter = annotations[key] = factory() if markers: for marker in markers: