design advice sought

Byron Morgan lazypointer at yahoo.com
Mon Jan 27 09:55:13 CET 2003


Thanks for the input - I have added threading for the messaging, and it
seems to be working.



"Dennis Lee Bieber" <wlfraed at ix.netcom.com> wrote in message
news:h37eg-im3.ln1 at beastie.ix.netcom.com...
> Byron Morgan fed this fish to the penguins on Saturday 25 January 2003
> 10:43 pm:
>
> > does this much pretty well, running all day. Next, I will add
> > functions to send messages via various transports (e.g., pager,
> > cellular text, instant mesaging) based on conditions and trends
> > detected or analyzed.
> >
>         How often do you expect to send these messages? Seldom, hourly,
etc.
>
>         Also, how complex do you expect the transport interface to be? If
all
> three have similar interfaces, and you don't have much load, I can
> visualize a scheme using:
>
>         main logging process
>                                 messaging thread started at init
>
>         send parameters to messaging thread via Queue.Queue (tuple?
> (transport, content))
>                                 thread reads queue, branching on transport
type
>
>
>         If the transport logic is fairly similar for all, you might
consider a
> base class (containing message content variables and empty methods to
> implement the transport), then subclasses inheriting from the base with
> specific methods for that type of transport...
>
> {pseudocode}
> class Message():
>         def __init__(self, address, content):
>                 self.address = address
>                 self.content = content
>         def sendit(self):
>                 print "UNDEFINED TRANSPORT"
>
> class MessagePager(Message):
>         def __init__(self, address, content):
>                 # maybe add some checks to ensure a valid pager "address"
>                 Message.__init__(self, address, content)
>         def sendif(self):
>                 #whatever code is needed to access the pager system
>
> #repeat for other types.
>
> Then the main process only has to do something like
>
>         amess = Message***(address, content)
>         queue.put(amess)
>
> the thread only needs to loop
>
>         am = queue.get()
>         am.sendit()
>
>
>
> --
>  > ============================================================== <
>  >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
>  >      wulfraed at dm.net     |       Bestiaria Support Staff       <
>  > ============================================================== <
>  >        Bestiaria Home Page: http://www.beastie.dm.net/         <
>  >            Home Page: http://www.dm.net/~wulfraed/             <
>






More information about the Python-list mailing list