code: def context_by_id(self, context_id, via_id=None, create=True, name=None):
          
          context = self._context_by_id.get(context_id)
          if context:
              return context
  
          if create and via_id is not None:
              via = self.context_by_id(via_id)
          else:
              via = None
  
          self._write_lock.acquire()
          try:
              context = self._context_by_id.get(context_id)
              if create and not context:
                  context = self.context_class(self, context_id, name=name)
                  context.via = via
                  self._context_by_id[context_id] = context
          finally:
              self._write_lock.release()
  
          return context
docs: Messy factory/lookup function to find a context by its ID, or construct
          it. This will eventually be replaced by a more sensible interface.