2019-01-05 20:43:48 +01:00
|
|
|
import os
|
|
|
|
from cbpi.api import *
|
|
|
|
from cbpi.controller.crud_controller import CRUDController
|
|
|
|
from cbpi.database.orm_framework import DBModel
|
|
|
|
from cbpi.http_endpoints.http_curd_endpoints import HttpCrudEndpoints
|
2018-12-06 23:46:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
class DummyModel(DBModel):
|
2018-12-08 14:21:00 +01:00
|
|
|
'''
|
|
|
|
Cumstom Data Model which will is stored in the database
|
|
|
|
'''
|
2018-12-06 23:46:06 +01:00
|
|
|
__fields__ = ["name"]
|
|
|
|
__table_name__ = "dummy"
|
2018-11-16 20:35:59 +01:00
|
|
|
|
2018-12-06 23:46:06 +01:00
|
|
|
|
2019-01-05 20:43:48 +01:00
|
|
|
class MyComp(CBPiExtension, CRUDController, HttpCrudEndpoints):
|
2018-12-06 23:46:06 +01:00
|
|
|
model = DummyModel
|
2018-11-16 20:35:59 +01:00
|
|
|
|
|
|
|
def __init__(self, cbpi):
|
|
|
|
'''
|
|
|
|
Initializer
|
|
|
|
:param cbpi:
|
|
|
|
'''
|
|
|
|
self.cbpi = cbpi
|
2018-12-08 14:21:00 +01:00
|
|
|
# register component for http, events
|
|
|
|
# In addtion the sub folder static is exposed to access static content via http
|
2019-01-05 20:43:48 +01:00
|
|
|
self.cbpi.register(self, "/dummy", static=os.path.join(os.path.dirname(__file__), "static"))
|
2018-12-06 23:46:06 +01:00
|
|
|
|
2018-11-16 20:35:59 +01:00
|
|
|
|
|
|
|
@on_event(topic="actor/#")
|
2018-12-13 21:45:33 +01:00
|
|
|
async def listen(self, **kwargs):
|
2019-08-16 21:36:55 +02:00
|
|
|
# Listen for all actor events
|
2018-12-29 00:27:19 +01:00
|
|
|
pass
|
2018-11-16 20:35:59 +01:00
|
|
|
|
2018-11-18 23:09:17 +01:00
|
|
|
@on_event(topic="kettle/+/automatic")
|
2018-12-13 21:45:33 +01:00
|
|
|
async def listen2(self, **kwargs):
|
2018-12-29 00:27:19 +01:00
|
|
|
|
2019-08-16 21:36:55 +02:00
|
|
|
# listen for all kettle events which are switching the automatic logic
|
2019-01-24 21:27:55 +01:00
|
|
|
pass
|
2018-11-18 23:09:17 +01:00
|
|
|
|
2018-12-06 23:46:06 +01:00
|
|
|
|
2018-11-16 20:35:59 +01:00
|
|
|
def setup(cbpi):
|
|
|
|
'''
|
|
|
|
Setup method is invoked during startup
|
|
|
|
|
|
|
|
:param cbpi: the cbpi core object
|
|
|
|
:return:
|
|
|
|
'''
|
|
|
|
# regsiter the component to the core
|
2018-12-07 00:18:35 +01:00
|
|
|
cbpi.plugin.register("MyComp", MyComp)
|
2019-08-16 21:36:55 +02:00
|
|
|
pass
|