def __init__(self, service_document_iri=None, 
                       user_name=None,
                       user_pass=None,
                       on_behalf_of=None,
                       download_service_document = False,   # Don't automagically GET the SD_IRI by default
                       keep_history=True,
                       cache_deposit_receipts=True,
                       honour_receipts=True,
                       error_response_raises_exceptions=True,
                       
                       # http layer implementation if different from default
                       http_impl=None,
                       ca_certs=None):
        self.sd_iri = service_document_iri
        self.sd = None
        
        # Client behaviour flags:
        # Honour deposit receipts - eg raise exceptions if interactions are attempted that the service document
        #                              does not allow without bothering the server - invalid packaging types, max upload sizes, etc
        self.honour_receipts = honour_receipts   
        
        # When error_response_raises_exceptions == True:
        # Error responses (HTTP codes >399) will raise exceptions (from sword2.exceptions) in response
        # when False:
        # Error Responses, if Content-Type is text/xml or application/xml, a sword2.error_document.Error_Document will be the 
        # return - No Exception will be raised!
        # Check Error_Document.code to get the response code, regardless to whether a valid Sword2 error document was received.
        self.raise_except = error_response_raises_exceptions
        
        self.keep_cache = cache_deposit_receipts
        
        # set the http layer
        if http_impl is None:
            conn_l.info("Loading default HTTP layer")
            self.h = http_layer.HttpLib2Layer(".cache", timeout=30.0, ca_certs=ca_certs)
        else:
            conn_l.info("Using provided HTTP layer")
            self.h = http_impl
        
        self.user_name = user_name
        self.on_behalf_of = on_behalf_of
        
        # Cached Deposit Receipt 'indexes'  *cough, cough*
        self.edit_iris = {}          # Key = IRI, Value = ref to latest Deposit Receipt for the resource
        self.cont_iris = {}          # Key = IRI, Value = ref to latest Deposit Receipt
        self.se_iris = {}            # Key = IRI, Value = ref to latest Deposit Receipt
        self.cached_at = {}          # Key = Edit-IRI, Value = Timestamp for when receipt was cached
        
        # Transaction history hooks
        self.history = None
        self._t = Timer()
        self.keep_history = keep_history
        if keep_history:
            conn_l.info("keep_history=True--> This instance will keep a JSON-compatible transaction log of all (SWORD/APP) activities in 'self.history'")
            self.reset_transaction_history()
            self.history.log('init',
                             sd_iri = self.sd_iri,
                             user_name = self.user_name,
                             on_behalf_of = self.on_behalf_of )
        # Add credentials to http client
        if user_name:
            conn_l.info("Adding username/password credentials for the client to use.")
            self.h.add_credentials(user_name, user_pass)
        
        if self.sd_iri and download_service_document:
            self._t.start("get_service_document")
            self.get_service_document()
            conn_l.debug("Getting service document and dealing with the response: %s s" % self._t.time_since_start("get_service_document")[1])
Each message written within the context of an L{Action} gets its
dataset/ETHPy150Open swordapp/python-client-sword2/sword2/connection.py/Connection.__init__--crossover with--dataset/ETHPy150Open ClusterHQ/eliot/eliot/tests/test_message.py/MessageTests.test_actionCounter