Ignore:
Timestamp:
Jan 30, 2016, 2:55:18 PM (3 years ago)
Author:
cito
Message:

Port type cache and typecasting from pgdb to pg

So far, the typecasting in the classic module was been only done by
the C extension module and was not extensible through typecasting
functions in Python. This has now been made extensible by adding
a cast hook to the C extension module which has been hooked up to
a new type cache object that holds information on the types and the
associated typecast functions. All of this works very similar to the
pgdb module now, except that the basic types are still handled by
the C extension module and the Python typecast functions are only
called via the hook for types which are not supported internally.

Also added tests and a chapter on the type cache in the documentation,
and cleaned up the error messages in the C extension module.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/test_classic_connection.py

    r781 r798  
    123123        methods = '''cancel close endcopy
    124124            escape_bytea escape_identifier escape_literal escape_string
    125             fileno get_notice_receiver getline getlo getnotify
     125            fileno get_cast_hook get_notice_receiver getline getlo getnotify
    126126            inserttable locreate loimport parameter putline query reset
    127             set_notice_receiver source transaction'''.split()
     127            set_cast_hook set_notice_receiver source transaction'''.split()
    128128        connection_methods = [a for a in dir(self.connection)
    129129            if not a.startswith('__') and self.is_method(a)]
     
    13251325
    13261326    def testSetNoticeReceiver(self):
    1327         self.assertRaises(TypeError, self.c.set_notice_receiver, None)
    13281327        self.assertRaises(TypeError, self.c.set_notice_receiver, 42)
     1328        self.assertRaises(TypeError, self.c.set_notice_receiver, 'invalid')
    13291329        self.assertIsNone(self.c.set_notice_receiver(lambda notice: None))
     1330        self.assertIsNone(self.c.set_notice_receiver(None))
    13301331
    13311332    def testSetAndGetNoticeReceiver(self):
     
    13331334        self.assertIsNone(self.c.set_notice_receiver(r))
    13341335        self.assertIs(self.c.get_notice_receiver(), r)
     1336        self.assertIsNone(self.c.set_notice_receiver(None))
     1337        self.assertIsNone(self.c.get_notice_receiver())
    13351338
    13361339    def testNoticeReceiver(self):
Note: See TracChangeset for help on using the changeset viewer.