# HG changeset patch # User Philippe Pepiot # Date 1484926784 -3600 # Node ID 7b2247098f58083921f8f130b1cc7e8eb048eb16 # Parent ad7796dabeaa13b84305aba879691c8bc354dbce [rtags] pass module name to RegistrableInstance Instantiate a RegistrableInstance without passing the module name is deprecated in https://www.logilab.org/patch/10047069 diff -r ad7796dabeaa -r 7b2247098f58 cubicweb/rtags.py --- a/cubicweb/rtags.py Fri Jan 27 17:42:16 2017 +0100 +++ b/cubicweb/rtags.py Fri Jan 20 16:39:44 2017 +0100 @@ -77,7 +77,8 @@ # function given as __init__ argument and kept for bw compat _init = _initfunc = None - def __init__(self, parent=None): + def __init__(self, parent=None, __module__=None): + super(RelationTags, self).__init__(__module__) self._tagdefs = {} self._parent = parent if parent is not None: @@ -143,7 +144,7 @@ >>> class_afs = uicfg.autoform_section.derive(__name__, is_instance('Class')) """ - copied = self.__class__(self) + copied = self.__class__(self, __module__=__name__) copied.__module__ = module copied.__select__ = select return copied diff -r ad7796dabeaa -r 7b2247098f58 cubicweb/test/unittest_rtags.py --- a/cubicweb/test/unittest_rtags.py Fri Jan 27 17:42:16 2017 +0100 +++ b/cubicweb/test/unittest_rtags.py Fri Jan 20 16:39:44 2017 +0100 @@ -16,7 +16,12 @@ # You should have received a copy of the GNU Lesser General Public License along # with CubicWeb. If not, see . -import unittest +import sys +if sys.version_info[:2] < (3, 2): + # assertWarns appears in 3.2 + import unittest2 as unittest +else: + import unittest from cubicweb.rtags import RelationTags, RelationTagsSet, RelationTagsDict @@ -24,7 +29,7 @@ class RelationTagsTC(unittest.TestCase): def setUp(self): - self.rtags = RelationTags() + self.rtags = RelationTags(__module__=__name__) self.rtags.tag_subject_of(('Societe', 'travaille', '*'), 'primary') self.rtags.tag_subject_of(('*', 'evaluee', '*'), 'secondary') self.rtags.tag_object_of(('*', 'tags', '*'), 'generated') @@ -64,7 +69,7 @@ class RelationTagsSetTC(unittest.TestCase): def setUp(self): - self.rtags = RelationTagsSet() + self.rtags = RelationTagsSet(__module__=__name__) self.rtags.tag_subject_of(('Societe', 'travaille', '*'), 'primary') self.rtags.tag_subject_of(('*', 'travaille', '*'), 'secondary') @@ -97,7 +102,7 @@ class RelationTagsDictTC(unittest.TestCase): def setUp(self): - self.rtags = RelationTagsDict() + self.rtags = RelationTagsDict(__module__=__name__) self.rtags.tag_subject_of(('Societe', 'travaille', '*'), {'key1': 'val1', 'key2': 'val1'}) self.rtags.tag_subject_of(('*', 'travaille', '*'), @@ -138,5 +143,17 @@ {'key0': 'val00', 'key4': 'val4'}) +class DeprecatedInstanceWithoutModule(unittest.TestCase): + + def test_deprecated_instance_without_module(self): + class SubRelationTags(RelationTags): + pass + with self.assertWarnsRegex( + DeprecationWarning, + 'instantiate SubRelationTags with __module__=__name__', + ): + SubRelationTags() + + if __name__ == '__main__': unittest.main() diff -r ad7796dabeaa -r 7b2247098f58 cubicweb/web/views/uicfg.py --- a/cubicweb/web/views/uicfg.py Fri Jan 27 17:42:16 2017 +0100 +++ b/cubicweb/web/views/uicfg.py Fri Jan 20 16:39:44 2017 +0100 @@ -91,7 +91,7 @@ self.tag_relation((sschema, rschema, oschema, role), section) -primaryview_section = PrimaryViewSectionRelationTags() +primaryview_section = PrimaryViewSectionRelationTags(__module__=__name__) class DisplayCtrlRelationTags(NoTargetRelationTagsDict): @@ -142,7 +142,7 @@ self.tag_object_of(('*', rtype, etype), {'order': index}) -primaryview_display_ctrl = DisplayCtrlRelationTags() +primaryview_display_ctrl = DisplayCtrlRelationTags(__module__=__name__) # index view configuration #################################################### @@ -485,7 +485,7 @@ self.edit_as_attr(self, etype, attr, formtype='muledit') -autoform_section = AutoformSectionRelationTags() +autoform_section = AutoformSectionRelationTags(__module__=__name__) # relations'field class @@ -505,7 +505,7 @@ self._tag_etype_attr(etype, attr, '*', field) -autoform_field = AutoformFieldTags() +autoform_field = AutoformFieldTags(__module__=__name__) # relations'field explicit kwargs (given to field's __init__) @@ -557,7 +557,7 @@ self._tag_etype_attr(etype, attr, '*', kwargs) -autoform_field_kwargs = AutoformFieldKwargsTags() +autoform_field_kwargs = AutoformFieldKwargsTags(__module__=__name__) # set of tags of the form _on_new on relations. is a @@ -567,7 +567,7 @@ __regid__ = 'autoform_permissions_overrides' -autoform_permissions_overrides = AutoFormPermissionsOverrides() +autoform_permissions_overrides = AutoFormPermissionsOverrides(__module__=__name__) class ReleditTags(NoTargetRelationTagsDict): @@ -629,7 +629,7 @@ {'novalue_include_rtype': not showlabel}) -reledit_ctrl = ReleditTags() +reledit_ctrl = ReleditTags(__module__=__name__) # boxes.EditBox configuration ################################################# @@ -684,7 +684,7 @@ self._tag_etype_attr(etype, attr, createdtype, False) -actionbox_appearsin_addmenu = ActionBoxUicfg() +actionbox_appearsin_addmenu = ActionBoxUicfg(__module__=__name__) def registration_callback(vreg): diff -r ad7796dabeaa -r 7b2247098f58 requirements/dev.txt --- a/requirements/dev.txt Fri Jan 27 17:42:16 2017 +0100 +++ b/requirements/dev.txt Fri Jan 20 16:39:44 2017 +0100 @@ -1,3 +1,3 @@ pytest -http://hg.logilab.org/master/logilab/common/archive/default.tar.bz2#egg=logilab-common +http://hg.logilab.org/review/logilab/common/archive/f8660aa.tar.bz2#egg=logilab-common http://hg.logilab.org/master/yams/archive/default.tar.bz2#egg=yams