Project

General

Profile

Bug #4569 » 0004-Fix-Use-RetryingQuery-where-possible-also-in-Hawat.patch

Radko Krkoš, 07/12/2019 01:50 PM

View differences:

lib/hawat/db.py
57 57
    if not _DB:
58 58
        _DB = flask_sqlalchemy.SQLAlchemy(
59 59
            metadata    = mentat.datatype.sqldb.MODEL.metadata,
60
            model_class = mentat.datatype.sqldb.MODEL
60
            model_class = mentat.datatype.sqldb.MODEL,
61
            query_class = mentat.services.sqlstorage.RetryingQuery
61 62
        )
62 63
        mentat.services.sqlstorage.set_manager(StorageServiceManager())
63 64

  
lib/mentat/datatype/test_sqldb.py
27 27
from mentat.datatype.sqldb import MODEL, UserModel, GroupModel, NetworkModel,\
28 28
    FilterModel, SettingsReportingModel, EventStatisticsModel, EventReportModel,\
29 29
    ItemChangeLogModel, jsondiff, usermodel_from_typeddict
30
from mentat.services.sqlstorage import RetryingQuery
30 31

  
31 32

  
32 33
#-------------------------------------------------------------------------------
......
50 51
    def setUp(self):
51 52
        self.dbengine = sqlalchemy.create_engine("postgresql://mentat:mentat@localhost/mentat_utest", echo = self.verbose)
52 53
        self.sessionmaker = sqlalchemy.orm.sessionmaker(bind = self.dbengine)
53
        self.session = self.sessionmaker()
54
        self.session = self.sessionmaker(query_cls = RetryingQuery)
54 55

  
55 56
        MODEL.metadata.drop_all(self.dbengine)
56 57
        MODEL.metadata.create_all(self.dbengine)
lib/mentat/services/sqlstorage.py
91 91
        """
92 92
        if self.session:
93 93
            self.session.close()
94
        self.session = self.sessionmaker()
94
        self.session = self.sessionmaker(query_cls = RetryingQuery)
95 95
        return self.session
96 96

  
97 97
    def database_create(self):
(4-4/4)