Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #7464 -- Fixed the psycopg2 backend to handle SafeString values as

parameters. Based on a patch from Digitalxero@gmail.com.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8532 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 29d216021375446223a36901ab0ec60b6e3eadf9 1 parent 62b3932
Malcolm Tredinnick authored August 25, 2008
3  django/db/backends/postgresql_psycopg2/base.py
@@ -10,8 +10,8 @@
10 10
 from django.db.backends.postgresql.creation import DatabaseCreation
11 11
 from django.db.backends.postgresql.version import get_version
12 12
 from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection
  13
+from django.utils.safestring import SafeUnicode, SafeString
13 14
 
14  
-from django.utils.safestring import SafeUnicode
15 15
 try:
16 16
     import psycopg2 as Database
17 17
     import psycopg2.extensions
@@ -23,6 +23,7 @@
23 23
 IntegrityError = Database.IntegrityError
24 24
 
25 25
 psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
  26
+psycopg2.extensions.register_adapter(SafeString, psycopg2.extensions.QuotedString)
26 27
 psycopg2.extensions.register_adapter(SafeUnicode, psycopg2.extensions.QuotedString)
27 28
 
28 29
 class DatabaseFeatures(BaseDatabaseFeatures):
6  tests/modeltests/field_defaults/models.py
@@ -49,8 +49,10 @@ def __unicode__(self):
49 49
 >>> d.seconds < 5
50 50
 True
51 51
 
52  
-# make sure that SafeUnicode fields work
53  
->>> from django.utils.safestring import SafeUnicode
  52
+# make sure that SafeString/SafeUnicode fields work
  53
+>>> from django.utils.safestring import SafeUnicode, SafeString
54 54
 >>> a.headline = SafeUnicode(u'SafeUnicode Headline')
55 55
 >>> a.save()
  56
+>>> a.headline = SafeString(u'SafeString Headline')
  57
+>>> a.save()
56 58
 """}

0 notes on commit 29d2160

Please sign in to comment.
Something went wrong with that request. Please try again.