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 = ``{`154735404`:` `{``'``aoe_code_mod_db``'``:` `[`<weakref at 0x9`...``
| 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:
      {154735404: {'aoe_code_mod_db': [<weakref at 0x9ca5784; to 'function'
      at 0x9955f7c (_on_code_link_modified)>],
                   'clin_narrative_mod_db': [<weakref at 0x9946d74; to 'func
      tion' at 0x99520d4 (_on_soap_modified)>],
                   'episode_code_mod_db': [<weakref at 0x9ca5874; to 'functi
      on' at 0x9955f7c (_on_code_link_modified)>],
                   'health_issue_code_mod_db': [<weakref at 0x9ca57fc; to 'f
      unction' at 0x9955f7c (_on_code_link_modified)>],
      ...