Package Gnumed :: Package pycommon :: Module gmDispatcher |
[frames] | no frames]

# Module gmDispatcher

source code

GNUmed client internal signal handling.

# this code has been written by Patrick O'Brien <pobrien@orbtech.com> # downloaded from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/87056

Classes
| DispatcherError
| BoundMethodWeakref BoundMethodWeakref class.

Functions
connect(receiver=None, signal=_Any(), sender=_Any(), weak=1) Connect receiver to sender for signal. | source code
disconnect(receiver, signal=_Any(), sender=_Any(), weak=1) Disconnect receiver from sender for signal. | source code
send(signal=None, sender=None, **kwds) Send signal from sender to all connected receivers. | source code
safeRef(object) Return a *safe* weak reference to a callable object. | source code

Variables
| wx_core_PyDeadObjectError = `None`
| known_signals = ``[``u'``current_encounter_modified``'``,` `u'``current_enco``...``
| connections = ``{`180127180`:` `{``'``aoe_code_mod_db``'``:` `[`<weakref at 0xb`...``
| senders = ``{``}``
| Any = `_Any()`
| __package__ = ``'``Gnumed.pycommon``'``

Imports: exceptions, types, sys, weakref, traceback, logging

Function Details

### connect(receiver=None, signal=_Any(), sender=_Any(), weak=1) | source code
    Connect receiver to sender for signal.

    If sender is Any, receiver will receive signal from any sender.
    If signal is Any, receiver will receive any signal from sender.
    If sender is None, receiver will receive signal from anonymous.
    If signal is Any and sender is None, receiver will receive any
            signal from anonymous.
    If signal is Any and sender is Any, receiver will receive any
            signal from any sender.
    If weak is true, weak references will be used.

    ADDITIONAL gnumed specific documentation:
                    this dispatcher is not designed with a gui single threaded event
                    loop in mind.
                    when connecting to a receiver that may eventually make calls to                 gui objects      such as wxWindows objects, it is highly recommended that any
    such calls be wrapped in wxCallAfter() e.g.
            def receiveSignal(self, **args):
                            self._callsThatDoNotTriggerGuiUpdates()
                            self.data = processArgs(args)
                            wxCallAfter( self._callsThatTriggerGuiUpdates() )

            since it is likely data change occurs before the signalling,
            it would probably look more simply like:

            def receiveSignal(self, **args):
                            wxCallAfter(self._updateUI() )

            def _updateUI(self):
                            # your code that reads data

            Especially if the widget can get a reference to updated data through
            a global reference, such as via gmCurrentPatient.

### disconnect(receiver, signal=_Any(), sender=_Any(), weak=1) | source code
Disconnect receiver from sender for signal. Disconnecting is not required. The use of disconnect is the same as for connect, only in reverse. Think of it as undoing a previous connection.

### send(signal=None, sender=None, **kwds) | source code
Send signal from sender to all connected receivers. Return a list of tuple pairs [(receiver, response), ... ]. If sender is None, signal is sent anonymously.

Variables Details

  ### known_signals Value:
      [u'current_encounter_modified',
       u'current_encounter_switched',
       u'encounter_mod_db',
       u'pre_patient_selection',
       u'post_patient_selection',
       u'patient_locked',
       u'patient_unlocked',
       u'import_document_from_file',
      ...

  ### connections Value:
      {180127180: {'aoe_code_mod_db': [<weakref at 0xb3c6464; to 'function'
      at 0xb4521ec (_on_code_link_modified)>],
                   'clin_narrative_mod_db': [<weakref at 0xb3c97ac; to 'func
      tion' at 0xb4544c4 (_on_soap_modified)>],
                   'episode_code_mod_db': [<weakref at 0xb3c62fc; to 'functi
      on' at 0xb4521ec (_on_code_link_modified)>],
                   'health_issue_code_mod_db': [<weakref at 0xb3c652c; to 'f
      unction' at 0xb4521ec (_on_code_link_modified)>],
      ...