Changeset 680 for trunk


Ignore:
Timestamp:
Dec 30, 2015, 4:56:42 PM (4 years ago)
Author:
cito
Message:

Remove the deprecated tty parameter and attribute

This parameter has been ignored by PostgreSQL since version 7.4.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/pg.rst

    r679 r680  
    5252---------------------------------------
    5353
    54 .. function:: connect([dbname], [host], [port], [opt], [tty], [user], [passwd])
     54.. function:: connect([dbname], [host], [port], [opt], [user], [passwd])
    5555
    5656    Open a :mod:`pg` connection
     
    6464    :param opt: connection options (*None* = :data:`defopt`)
    6565    :type opt: str or None
    66     :param tty: debug terminal (*None* = :data:`deftty`)
    67     :type tty: str or None
    6866    :param user: PostgreSQL user (*None* = :data:`defuser`)
    6967    :type user: str or None
     
    176174If ``None`` is supplied as parameter, environment variables will be used in
    177175future connections. It returns the previous setting for default options.
    178 
    179 get/set_deftty -- default debug tty [DV]
    180 ----------------------------------------
    181 
    182 .. function:: get_deftty()
    183 
    184     Get the default debug terminal
    185 
    186     :returns: the current default debug terminal specification
    187     :rtype: str or None
    188     :raises TypeError: too many arguments
    189 
    190 This method returns the current default debug terminal specification, or
    191 ``None`` if the environment variables should be used. Environment variables
    192 won't be looked up.
    193 
    194 .. function:: set_deftty(terminal)
    195 
    196     Set the default debug terminal
    197 
    198     :param terminal: the new default debug terminal
    199     :type terminal: str or None
    200     :returns: the previous default debug terminal specification
    201     :rtype: str or None
    202     :raises TypeError: bad argument type, or too many arguments
    203 
    204 This methods sets the default debug terminal value for new connections.
    205 If ``None`` is supplied as parameter, environment variables will be used
    206 in future connections. It returns the previous setting for default terminal.
    207176
    208177get/set_defbase -- default database name [DV]
     
    840809
    841810   the connection options (str)
    842 
    843 .. attribute:: Connection.tty
    844 
    845    the connection debug terminal (str)
    846811
    847812.. attribute:: Connection.user
  • trunk/docs/pgdb.rst

    r679 r680  
    5555database and returns a :class:`Connection` object using these parameters.
    5656If specified, the *dsn* parameter must be a string with the format
    57 ``'host:base:user:passwd:opt:tty'``. All of the parts specified in the *dsn*
     57``'host:base:user:passwd:opt'``. All of the parts specified in the *dsn*
    5858are optional. You can also specify the parameters individually using keyword
    5959arguments, which always take precedence. The *host* can also contain a port
    6060if specified in the format ``'host:port'``. In the *opt* part of the *dsn*
    61 you can pass command-line options to the server, the *tty* part is used to
    62 send server debug output.
     61you can pass command-line options to the server.
    6362
    6463Example::
  • trunk/module/pgdb.py

    r679 r680  
    2020
    2121    pgdb.connect(connect_string) # open a connection
    22     # connect_string = 'host:database:user:password:opt:tty'
     22    # connect_string = 'host:database:user:password:opt'
    2323    # All parts are optional. You may also pass host through
    2424    # password as keyword arguments. To pass a port,
     
    567567    dbpasswd = ""
    568568    dbopt = ""
    569     dbtty = ""
    570569    try:
    571570        params = dsn.split(":")
     
    575574        dbpasswd = params[3]
    576575        dbopt = params[4]
    577         dbtty = params[5]
    578576    except (AttributeError, IndexError, TypeError):
    579577        pass
     
    601599
    602600    # open the connection
    603     cnx = _connect_(dbbase, dbhost, dbport, dbopt,
    604         dbtty, dbuser, dbpasswd)
     601    cnx = _connect_(dbbase, dbhost, dbport, dbopt, dbuser, dbpasswd)
    605602    return Connection(cnx)
    606603
  • trunk/module/pgmodule.c

    r655 r680  
    101101static PyObject *pg_default_base;       /* default database name */
    102102static PyObject *pg_default_opt;        /* default connection options */
    103 static PyObject *pg_default_tty;        /* default debug tty */
    104103static PyObject *pg_default_port;       /* default connection port */
    105104static PyObject *pg_default_user;       /* default username */
     
    23082307
    23092308        attrs = PyObject_Dir(PyObject_Type((PyObject *)self));
    2310         PyObject_CallMethod(attrs, "extend", "[ssssssssss]",
    2311                 "host", "port", "db", "options", "tty", "error", "status", "user",
     2309        PyObject_CallMethod(attrs, "extend", "[sssssssss]",
     2310                "host", "port", "db", "options", "error", "status", "user",
    23122311                "protocol_version", "server_version");
    23132312
     
    24052404        if (!strcmp(name, "options"))
    24062405                return PyStr_FromString(PQoptions(self->cnx));
    2407 
    2408         /* selected postgres tty */
    2409         if (!strcmp(name, "tty"))
    2410                 return PyStr_FromString(PQtty(self->cnx));
    24112406
    24122407        /* error (status) message */
     
    31703165/* connects to a database */
    31713166static char pgConnect__doc__[] =
    3172 "connect(dbname, host, port, opt, tty) -- connect to a PostgreSQL database "
     3167"connect(dbname, host, port, opt) -- connect to a PostgreSQL database "
    31733168"using specified parameters (optionals, keywords aware).";
    31743169
     
    31773172{
    31783173        static const char *kwlist[] = {"dbname", "host", "port", "opt",
    3179         "tty", "user", "passwd", NULL};
     3174        "user", "passwd", NULL};
    31803175
    31813176        char       *pghost,
    31823177                           *pgopt,
    3183                            *pgtty,
    31843178                           *pgdbname,
    31853179                           *pguser,
     
    31893183        connObject   *npgobj;
    31903184
    3191         pghost = pgopt = pgtty = pgdbname = pguser = pgpasswd = NULL;
     3185        pghost = pgopt = pgdbname = pguser = pgpasswd = NULL;
    31923186        pgport = -1;
    31933187
     
    31983192         * I try to assign all those constant strings to it.
    31993193         */
    3200         if (!PyArg_ParseTupleAndKeywords(args, dict, "|zzizzzz", (char **) kwlist,
    3201                 &pgdbname, &pghost, &pgport, &pgopt, &pgtty, &pguser, &pgpasswd))
     3194        if (!PyArg_ParseTupleAndKeywords(args, dict, "|zzizzz", (char **) kwlist,
     3195                &pgdbname, &pghost, &pgport, &pgopt, &pguser, &pgpasswd))
    32023196                return NULL;
    32033197
     
    32133207                pgopt = PyBytes_AsString(pg_default_opt);
    32143208
    3215         if ((!pgtty) && (pg_default_tty != Py_None))
    3216                 pgtty = PyBytes_AsString(pg_default_tty);
    3217 
    32183209        if ((!pgdbname) && (pg_default_base != Py_None))
    32193210                pgdbname = PyBytes_AsString(pg_default_base);
     
    32463237#endif
    32473238        npgobj->cnx = PQsetdbLogin(pghost, pgport == -1 ? NULL : port_buffer,
    3248                 pgopt, pgtty, pgdbname, pguser, pgpasswd);
     3239                pgopt, NULL, pgdbname, pguser, pgpasswd);
    32493240#ifdef PQsetdbLoginIsThreadSafe
    32503241        Py_END_ALLOW_THREADS
     
    44244415}
    44254416
    4426 /* gets default tty */
    4427 static char pgGetDefTTY__doc__[] =
    4428 "get_deftty() -- return default database debug terminal.";
    4429 
    4430 static PyObject *
    4431 pgGetDefTTY(PyObject *self, PyObject *args)
    4432 {
    4433         /* checks args */
    4434         if (!PyArg_ParseTuple(args, ""))
    4435         {
    4436                 PyErr_SetString(PyExc_TypeError,
    4437                         "method get_deftty() takes no parameter.");
    4438                 return NULL;
    4439         }
    4440 
    4441         Py_XINCREF(pg_default_tty);
    4442         return pg_default_tty;
    4443 }
    4444 
    4445 /* sets default tty */
    4446 static char pgSetDefTTY__doc__[] =
    4447 "set_deftty(string) -- set default database debug terminal. "
    4448 "Return previous value.";
    4449 
    4450 static PyObject *
    4451 pgSetDefTTY(PyObject *self, PyObject *args)
    4452 {
    4453         char       *temp = NULL;
    4454         PyObject   *old;
    4455 
    4456         /* gets arguments */
    4457         if (!PyArg_ParseTuple(args, "z", &temp))
    4458         {
    4459                 PyErr_SetString(PyExc_TypeError,
    4460                         "set_deftty(name), with name (string/None).");
    4461                 return NULL;
    4462         }
    4463 
    4464         /* adjusts value */
    4465         old = pg_default_tty;
    4466 
    4467         if (temp)
    4468                 pg_default_tty = PyStr_FromString(temp);
    4469         else
    4470         {
    4471                 Py_INCREF(Py_None);
    4472                 pg_default_tty = Py_None;
    4473         }
    4474 
    4475         return old;
    4476 }
    4477 
    44784417/* gets default username */
    44794418static char pgGetDefUser__doc__[] =
     
    46434582        {"get_defopt", pgGetDefOpt, METH_VARARGS, pgGetDefOpt__doc__},
    46444583        {"set_defopt", pgSetDefOpt, METH_VARARGS, pgSetDefOpt__doc__},
    4645         {"get_deftty", pgGetDefTTY, METH_VARARGS, pgGetDefTTY__doc__},
    4646         {"set_deftty", pgSetDefTTY, METH_VARARGS, pgSetDefTTY__doc__},
    46474584        {"get_defport", pgGetDefPort, METH_VARARGS, pgGetDefPort__doc__},
    46484585        {"set_defport", pgSetDefPort, METH_VARARGS, pgSetDefPort__doc__},
     
    47754712        pg_default_port = Py_None;
    47764713        Py_INCREF(Py_None);
    4777         pg_default_tty = Py_None;
    4778         Py_INCREF(Py_None);
    47794714        pg_default_user = Py_None;
    47804715        Py_INCREF(Py_None);
  • trunk/module/tests/test_classic_connection.py

    r655 r680  
    116116    def testAllConnectAttributes(self):
    117117        attributes = '''db error host options port
    118             protocol_version server_version status tty user'''.split()
     118            protocol_version server_version status user'''.split()
    119119        connection_attributes = [a for a in dir(self.connection)
    120120            if not a.startswith('__') and not self.is_method(a)]
     
    167167        self.assertIsInstance(self.connection.status, int)
    168168        self.assertEqual(self.connection.status, status_ok)
    169 
    170     def testAttributeTty(self):
    171         def_tty = ''
    172         self.assertIsInstance(self.connection.tty, str)
    173         self.assertEqual(self.connection.tty, def_tty)
    174169
    175170    def testAttributeUser(self):
  • trunk/module/tests/test_classic_dbwrapper.py

    r664 r680  
    131131            'status',
    132132            'transaction',
    133             'tty',
    134133            'unescape_bytea',
    135134            'update',
     
    191190        self.assertEqual(status, status_ok)
    192191        self.assertEqual(status, self.db.db.status)
    193 
    194     def testAttributeTty(self):
    195         def_tty = ''
    196         tty = self.db.tty
    197         self.assertIsInstance(tty, str)
    198         self.assertEqual(tty, def_tty)
    199         self.assertEqual(tty, self.db.db.tty)
    200192
    201193    def testAttributeUser(self):
  • trunk/module/tests/test_classic_functions.py

    r648 r680  
    248248        self.assertEqual(pg.get_defopt(), d0)
    249249
    250     def testDefTty(self):
    251         d0 = pg.get_deftty()
    252         d1 = 'pgtesttty'
    253         pg.set_deftty(d1)
    254         self.assertEqual(pg.get_deftty(), d1)
    255         pg.set_deftty(d0)
    256         self.assertEqual(pg.get_deftty(), d0)
    257 
    258250    def testDefBase(self):
    259251        d0 = pg.get_defbase()
Note: See TracChangeset for help on using the changeset viewer.