Code Duplication    Length = 24-28 lines in 2 locations

groundwork_web/patterns/gw_web_db_admin_pattern/gw_web_db_admin_pattern.py 1 location

@@ 27-54 (lines=28) @@
24
        self.web.db = WebDatabasePlugin(self)
25
26
27
class WebDatabasePlugin:
28
    def __init__(self, plugin):
29
        self.plugin = plugin
30
        self.app = plugin.app
31
        self.log = plugin.log
32
33
        # Let's register a receiver, which cares about the deactivation process of web_databases for this plugin.
34
        # We do it after the original plugin deactivation, so we can be sure that the registered function is the last
35
        # one which cares about web_databases for this plugin.
36
        self.plugin.signals.connect(receiver="%s_web_db_deactivation" % self.plugin.name,
37
                                    signal="plugin_deactivate_post",
38
                                    function=self.__deactivate_web_db,
39
                                    description="Deactivates web databases for %s" % self.plugin.name,
40
                                    sender=self.plugin)
41
        self.log.debug("Pattern web database initialised")
42
43
    def register(self, db_clazz, db_session):
44
        self.app.web.db.register(db_clazz, db_session)
45
46
    def unregister(self):
47
        pass
48
49
    def get(self):
50
        # REALLY needed?
51
        pass
52
53
    def __deactivate_web_db(self, plugin, *args, **kwargs):
54
        pass
55
56
57
class WebDatabaseApplication:

groundwork_web/patterns/gw_web_db_rest_pattern/gw_web_db_rest_pattern.py 1 location

@@ 26-49 (lines=24) @@
23
        self.web.rest = WebRestPlugin(self)
24
25
26
class WebRestPlugin:
27
    def __init__(self, plugin):
28
        self.plugin = plugin
29
        self.app = plugin.app
30
        self.log = plugin.log
31
32
        # Let's register a receiver, which cares about the deactivation process of web_databases for this plugin.
33
        # We do it after the original plugin deactivation, so we can be sure that the registered function is the last
34
        # one which cares about web_databases for this plugin.
35
        self.plugin.signals.connect(receiver="%s_web_rest_deactivation" % self.plugin.name,
36
                                    signal="plugin_deactivate_post",
37
                                    function=self.__deactivate_web_rest,
38
                                    description="Deactivates web rest apis for %s" % self.plugin.name,
39
                                    sender=self.plugin)
40
        self.log.debug("Pattern web rest initialised")
41
42
    def register(self, db_clazz, db_session):
43
        self.app.web.rest.register(db_clazz, db_session)
44
45
    def unregister(self):
46
        pass
47
48
    def __deactivate_web_rest(self, plugin, *args, **kwargs):
49
        pass
50
51
52
class WebRestApplication: