Issue 10796

Crash tests __slots__ when Mixin is not from trytond module
Nosy list
pokoli, resteve
Assigned to

Created on 2021-09-27.13:33:03 by resteve, last changed 2 months ago by pokoli.


Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2021-09-27.14:11:38

I do not see anything that we can do to fix your code. Also, this is not the current place for getting developer support, please use the forum for that.

Author: [hidden] (resteve)
Date: 2021-09-27.13:58:44


thanks for your repply, but the test also check all Mixin classes. Example:

from flask_login import UserMixin
from trytond.model import ModelView, ModelSQL

class GalateaUserMixin(UserMixin):
__slots__ = ()

class GalateaUserMixin(ModelSQL, ModelView, GalateaUserMixin):
"""Galatea Users"""
__name__ = "galatea.user"

Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2021-09-27.13:49:46

You can just create a derivative Mixin which inherits everything from flask and sets the proper slots.

Author: [hidden] (resteve)
Date: 2021-09-27.13:44:09

See that the Mixin is from Flask [1].

It's an example that the Mixin can't add "__slots__".

Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2021-09-27.13:34:46

You should define the slots on your mixins as other modules do.
There is nothing to fix on the tryton project.

Author: [hidden] (resteve)
Date: 2021-09-27.13:33:02

Since issue10719 , the test add check __slots__ but in case a class import from other class that is not trytond module, has not __slot__ is not defined.

Traceback (most recent call last):
File "/home/raimon/projectes/nandev/nancore/trytond/trytond/tests/", line 204, in wrapper
result = func(args, *kwargs)
File "/home/raimon/projectes/nandev/nancore/trytond/trytond/tests/", line 761, in test_pool_slots
% (kls, type_, name))
AssertionError: False is not true : The <class 'flask_login.mixins.UserMixin'> of model 'galatea.user' has no __slots__

Date User Action Args
2021-09-27 14:11:47pokolisetstatus: chatting -> invalid
2021-09-27 14:11:38pokolisetmessages: + msg70435
2021-09-27 13:58:49restevesetstatus: invalid -> chatting
2021-09-27 13:58:44restevesetmessages: + msg70434
2021-09-27 13:49:46pokolisetmessages: + msg70433
status: chatting -> invalid
2021-09-27 13:44:09restevesetmessages: + msg70432
status: invalid -> chatting
2021-09-27 13:34:46pokolisetmessages: + msg70431
nosy: + pokoli
status: chatting -> invalid
2021-09-27 13:33:03restevecreate

Showing 10 items. Show all history (warning: this could be VERY long)