summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2013-01-11 12:07:10 +0100
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2013-01-11 12:07:10 +0100
commit942ef514462522c0ea250fbc402e5ae67fbeaf5e (patch)
tree3e6ef37bd6df0532df1ab9bf01a276cae1024d6d
parent247b86271595f52cecfd4c998442f6e5c5ae7014 (diff)
downloadlogilab-common-942ef514462522c0ea250fbc402e5ae67fbeaf5e.tar.gz
[registry]?deprecate usage of leading underscore to mark class as abstract / not to register
-rw-r--r--ChangeLog3
-rw-r--r--registry.py10
2 files changed, 10 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index d642350..ac74ea0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,9 @@ ChangeLog for logilab.common
* registry:
- introduce objid and objname methods on Registry instead of classid
function and inlined code (closes #98742)
+ - deprecate usage of leading underscore to skip object registration, using
+ __abstract__ explicitly is better and notion of registered object 'name'
+ is now somewhat fuzzy
* loggin_ext: on windows, use colorama to display colored logs, if available (closes #107436)
diff --git a/registry.py b/registry.py
index 05b8b2e..7a4072c 100644
--- a/registry.py
+++ b/registry.py
@@ -670,8 +670,7 @@ class RegistryStore(dict):
- first ensure parent classes are already registered
- - class with __abstract__ == True in their local dictionary or
- with a name starting with an underscore are not registered
+ - class with __abstract__ == True in their local dictionary are skipped
- object class needs to have __registry__ and __regid__ attributes
set to a non empty string to be registered.
@@ -696,8 +695,13 @@ class RegistryStore(dict):
self._loadedmods[modname][clsid] = objectcls
for parent in objectcls.__bases__:
self._load_ancestors_then_object(modname, parent)
+ if reg.objname(obj)[0] == '_':
+ warn("[lgc 0.59] object whose name start with '_' won't be "
+ "skipped anymore at some point, use __abstract__ = True "
+ "instead (%s)" % obj, DeprecationWarning)
+ return
+
if (objectcls.__dict__.get('__abstract__')
- or objectcls.__name__[0] == '_'
or not objectcls.__registries__
or not objectcls.__regid__):
return