[Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

prilisauer at googlemail.com prilisauer at googlemail.com
Sat Dec 22 21:43:12 CET 2012


Am Samstag, 22. Dezember 2012 20:29:49 UTC+1 schrieb Alexander Blinne:
> Am 22.12.2012 19:10, schrieb:
> 
> > 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


I Think I describe my Situation wrong, the written Project is a
Server, that should store sensor data, perfoms makros on lamps according
a sequence stored in the DB and Rule systems schould regulate home devices and plan scheduler jobs so on.

The System Runs in a threated environment. It looks for me, like the limits are at the end of file. my core problem also the only one I have is: I don't know how to get over that limits and enable dataexchange like a backbone...




More information about the Python-list mailing list