Gnumed.pycommon.gmDispatcher

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 = ``{`204657836`:` `{``'``clin.aoe_code_mod_db``'``:` `[`<weakref a`...``
| 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'pre_patient_selection',
       u'post_patient_selection',
       u'patient_locked',
       u'patient_unlocked',
       u'import_document_from_file',
       u'import_document_from_files',
      ...

  ### connections Value:
      {204657836: {'clin.aoe_code_mod_db': [<weakref at 0xcca03ec; to 'funct
      ion' at 0xcbda454 (_on_code_link_modified)>],
                   'clin.clin_narrative_mod_db': [<weakref at 0xcca8504; to
      'function' at 0xcbe310c (_on_soap_modified)>],
                   'clin.episode_code_mod_db': [<weakref at 0xcca0234; to 'f
      unction' at 0xcbda454 (_on_code_link_modified)>],
                   'clin.health_issue_code_mod_db': [<weakref at 0xcca0414;
      to 'function' at 0xcbda454 (_on_code_link_modified)>],
      ...