Ticket #13161: patch-r12807.diff

File patch-r12807.diff, 1.6 KB (added by spoksss, 15 years ago)

diff file

  • base.py

     
    2626DatabaseError = Database.DatabaseError
    2727IntegrityError = Database.IntegrityError
    2828
    29 psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
    3029psycopg2.extensions.register_adapter(SafeString, psycopg2.extensions.QuotedString)
    3130psycopg2.extensions.register_adapter(SafeUnicode, psycopg2.extensions.QuotedString)
    3231
     
    9897
    9998    def __init__(self, *args, **kwargs):
    10099        super(DatabaseWrapper, self).__init__(*args, **kwargs)
    101 
     100        self._set_extension()
    102101        self.features = DatabaseFeatures()
    103102        autocommit = self.settings_dict["OPTIONS"].get('autocommit', False)
    104103        self.features.uses_autocommit = autocommit
     
    108107        self.creation = DatabaseCreation(self)
    109108        self.introspection = DatabaseIntrospection(self)
    110109        self.validation = BaseDatabaseValidation(self)
    111 
     110   
     111    def _set_extension(self):
     112        if self.connection:
     113            psycopg2.extensions.register_type(psycopg2.extensions.UNICODE,  self.connection)
     114   
    112115    def _cursor(self):
    113116        new_connection = False
    114117        set_tz = False
     
    134137            if settings_dict['PORT']:
    135138                conn_params['port'] = settings_dict['PORT']
    136139            self.connection = Database.connect(**conn_params)
     140            self._set_extension()
    137141            self.connection.set_client_encoding('UTF8')
    138142            self.connection.set_isolation_level(self.isolation_level)
    139143            connection_created.send(sender=self.__class__)
Back to Top