Am 22.12.2012 19:10, schrieb prilisa...@googlemail.com:
> It's for me a view of top side down, but how could the midlevel comunicate to 
> each oter... "not hirachical"

You could use something like the singleton pattern in order to get a
reference to the same datastore-object every time Datastore.Datastore()
is called. But you still need to close the connection properly at some
point, propably using a classmethod Datastore.close().

e.g.:

main.py:

from Datastore import Datastore
from ModbusClient import Modbus
from DaliBusClient import DaliBus

def main():
    modbus = Modbus(...)
    dalibus = DaliBus(...)

    modbus.read_data_and_save_to_store()
    dalibus.read_data_and_save_to_store()
    Datastore.close()

if __name__=="__main__":
    main()


ModbusClient.py:

import Datastore

class Modbus(object):
    def read_data_and_save_to_store(self):
        datastore = Datastore.Datastore()
        #do something with datastore
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to