@@ -50,14 +50,6 @@ def create_replication(self, source_db=None, target_db=None,
5050 ``CouchDatabase`` or ``CloudantDatabase`` instance.
5151 :param str repl_id: Optional replication id. Generated internally if
5252 not explicitly set.
53- :param source: Optional ``str`` or ``dict`` representing the source
54- database, along with authentication info, if any. Composed
55- internally if not explicitly set and not in CouchDB Admin Party
56- mode.
57- :param target: Optional ``str`` or ``dict`` representing the
58- target database, possibly including authentication info. Composed
59- internally if not explicitly set and not in CouchDB Admin Party
60- mode.
6153 :param dict user_ctx: Optional user to act as. Composed internally
6254 if not explicitly set and not in CouchDB Admin Party
6355 mode.
@@ -74,26 +66,25 @@ def create_replication(self, source_db=None, target_db=None,
7466 ** kwargs
7567 )
7668
77- if not data .get ('source' ):
78- if source_db is None :
79- raise CloudantReplicatorException (101 )
80- data ['source' ] = {'url' : source_db .database_url }
81- if not source_db .admin_party :
82- data ['source' ].update (
83- {'headers' : {'Authorization' : source_db .creds ['basic_auth' ]}}
84- )
85-
86- if not data .get ('target' ):
87- if target_db is None :
88- raise CloudantReplicatorException (102 )
89- data ['target' ] = {'url' : target_db .database_url }
90- if not target_db .admin_party :
91- data ['target' ].update (
92- {'headers' : {'Authorization' : target_db .creds ['basic_auth' ]}}
93- )
69+ if source_db is None :
70+ raise CloudantReplicatorException (101 )
71+ data ['source' ] = {'url' : source_db .database_url }
72+ if not source_db .admin_party :
73+ data ['source' ].update (
74+ {'headers' : {'Authorization' : source_db .creds ['basic_auth' ]}}
75+ )
76+
77+ if target_db is None :
78+ raise CloudantReplicatorException (102 )
79+ data ['target' ] = {'url' : target_db .database_url }
80+ if not target_db .admin_party :
81+ data ['target' ].update (
82+ {'headers' : {'Authorization' : target_db .creds ['basic_auth' ]}}
83+ )
9484
9585 if not data .get ('user_ctx' ):
96- if not target_db .admin_party :
86+ if (target_db and not target_db .admin_party or
87+ self .database .creds ):
9788 data ['user_ctx' ] = self .database .creds ['user_ctx' ]
9889
9990 return self .database .create_document (data , throw_on_exists = True )
0 commit comments