trytond: Fix Pool.setup to re-allow extra_depends behavior (issue 898002)

23 views
Skip to first unread message

cedric...@b2ck.com

unread,
May 23, 2013, 10:54:15 AM5/23/13
to cedric...@b2ck.com, re...@tryton-rietveld-hrd.appspotmail.com, tryto...@googlegroups.com
Reviewers: ,

Description:
trytond: Fix Pool.setup to re-allow extra_depends behavior

Please review this at http://codereview.tryton.org/898002/

Affected files:
M trytond/pool.py


Index: trytond/pool.py
===================================================================
--- a/trytond/pool.py
+++ b/trytond/pool.py
@@ -62,6 +62,7 @@
for cls in classes:
mpool = Pool.classes[type_].setdefault(module, [])
assert cls not in mpool, cls
+ assert issubclass(cls.__class__, PoolMeta)
mpool.append(cls)

@classmethod
@@ -194,6 +195,9 @@
Setup classes for module and return a list of classes for each
type in
a dictionary.
'''
+ from trytond.model import Model
+ from trytond.wizard import Wizard
+ from trytond.report import Report
classes = {}
for type_ in self.classes.keys():
classes[type_] = []
@@ -203,11 +207,9 @@
cls = type(cls.__name__, (cls, previous_cls), {})
except KeyError:
pass
- if (not hasattr(cls, '__setup__')
- and issubclass(cls.__class__, PoolMeta)):
+ if not issubclass(cls, (Model, Wizard, Report)):
continue
- else:
- cls.__setup__()
+ cls.__setup__()
self.add(cls, type=type_)
classes[type_].append(cls)
for cls in classes[type_]:


Cédric Krier

unread,
May 23, 2013, 11:27:27 AM5/23/13
to tryto...@googlegroups.com
I'm not very happy to have to import Model, Wizard and Report in Pool.
If anyone has a better idea, you are welcome.

--
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: cedric...@b2ck.com
Website: http://www.b2ck.com/

Jean C

unread,
May 23, 2013, 11:34:03 AM5/23/13
to tryto...@googlegroups.com
I'm not very happy to have to import Model, Wizard and Report in Pool.
If anyone has a better idea, you are welcome.

Wouldn't it be possible to add a "setup_needed" classmethod which would
be used to decide whether the __setup__ method should be called ?

Jean CAVALLO
Coopengo

Cédric Krier

unread,
May 23, 2013, 1:12:51 PM5/23/13
to tryto...@googlegroups.com
Yep, I updated the review to use a common Base class.
Reply all
Reply to author
Forward
0 new messages