11
11
from django .contrib .contenttypes .models import ContentType
12
12
from djangomarkup .models import SourceText , TextProcessor
13
13
from djangomarkup .widgets import RichTextAreaWidget
14
- from djangomarkup .processors import ProcessorConfigurationError , ProcessorError
14
+ from djangomarkup .processors import ProcessorError
15
15
16
16
RICH_FIELDS_SET = '__rich_fields_list'
17
17
SRC_TEXT_ATTR = '__src_text'
@@ -22,14 +22,18 @@ class UnicodeWrapper(unicode):
22
22
def __str__ (self ):
23
23
return smart_str (self )
24
24
25
- if settings .DATABASE_ENGINE == 'postgresql_psycopg2' :
26
25
def __conform__ (self , x ):
27
- # hack to enable psycopg2's adapting to work
28
- # on something that is not a unicode
29
- from psycopg2 .extensions import adapt
30
- return adapt (unicode (self ))
31
- UnicodeWrapper .__conform__ = __conform__
32
-
26
+ try :
27
+ engine = settings .DATABASES ['default' ]['ENGINE' ].split ('.' )[- 1 ]
28
+ except (KeyError , AttributeError ):
29
+ engine = getattr (settings , 'DATABASE_ENGINE' , '' ).split ('.' )[- 1 ]
30
+
31
+ if engine .startswith ('postgresql' ):
32
+ # hack to enable psycopg2's adapting to work
33
+ # on something that is not a unicode
34
+ from psycopg2 .extensions import adapt
35
+ return adapt (unicode (self ))
36
+ return unicode (self )
33
37
34
38
def post_save_listener (sender , instance , src_text_attr = SRC_TEXT_ATTR , ** kwargs ):
35
39
src_texts = []
0 commit comments