@@ -527,10 +527,7 @@ cdef class ConnectParamsImpl:
527527
528528 def get_connect_string (self ):
529529 """
530- Internal method for getting the connect string. This will either be the
531- connect string supplied to parse_connect_string() or parse_dsn(), or it
532- will be a connect string built up from the components supplied when the
533- object was built.
530+ Returns a connect string generated from the parameters.
534531 """
535532 return self .description_list.build_connect_string()
536533
@@ -557,28 +554,28 @@ cdef class ConnectParamsImpl:
557554 errors._raise_err(errors.ERR_CANNOT_PARSE_CONNECT_STRING, cause = e,
558555 data = connect_string)
559556
560- def parse_dsn (self , str dsn , bint parse_connect_string ):
557+ def parse_dsn_with_credentials (self , str dsn ):
561558 """
562559 Parse a dsn (data source name) string supplied by the user. This can be
563- in the form user/password@connect_string or it can be a simple connect
564- string . The connect string is returned and the user, proxy_user and
565- password values are retained .
560+ in the form user/password@connect_string or it can be in the form
561+ user/password . The user, password and connect string are returned in a
562+ 3-tuple .
566563 """
567- connect_string = dsn
568564 pos = dsn.rfind(" @" )
569565 if pos >= 0 :
570566 credentials = dsn[:pos]
571- connect_string = dsn[pos + 1 :]
572- pos = credentials.find(" /" )
573- if pos >= 0 :
574- user = credentials[:pos]
575- self ._set_password(credentials[pos + 1 :])
576- else :
577- user = credentials
578- self .parse_user(user)
579- if parse_connect_string:
580- self .parse_connect_string(connect_string)
581- return connect_string
567+ connect_string = dsn[pos + 1 :] or None
568+ else :
569+ credentials = dsn
570+ connect_string = None
571+ pos = credentials.find(" /" )
572+ if pos >= 0 :
573+ user = credentials[:pos] or None
574+ password = credentials[pos + 1 :] or None
575+ else :
576+ user = credentials or None
577+ password = None
578+ return (user, password, connect_string)
582579
583580 def parse_user (self , str user ):
584581 """
@@ -593,6 +590,30 @@ cdef class ConnectParamsImpl:
593590 else :
594591 self .user = user
595592
593+ def process_args (self , str dsn , dict kwargs , bint thin ):
594+ """
595+ Processes the arguments to connect() and create_pool().
596+
597+ - the keyword arguments are set
598+ - if no user was specified in the keyword arguments and a dsn is
599+ specified, it is parsed to determine the user, password and
600+ connect string and the user and password are stored
601+ - in thin mode, the connect string is then parsed into its
602+ components and stored
603+ - if no dsn was specified, one is built from the components
604+ - the connect string is returned
605+ """
606+ if kwargs:
607+ self .set(kwargs)
608+ if self .user is None and dsn is not None :
609+ user, password, dsn = self .parse_dsn_with_credentials(dsn)
610+ self .set(dict (user = user, password = password))
611+ if dsn is not None and thin:
612+ self .parse_connect_string(dsn)
613+ if dsn is None :
614+ dsn = self .get_connect_string()
615+ return dsn
616+
596617
597618cdef class Address:
598619 """
0 commit comments