update copyright date
[matthijs/upstream/django-ldapdb.git] / ldapdb / models / fields.py
index fe91601f6053d8c9c74d27f3e330f880201d242d..6162c7f5a21bdca57be1e4d403d540446b799803 100644 (file)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 # 
 # django-ldapdb
-# Copyright (C) 2009 BollorĂ© telecom
+# Copyright (C) 2009-2010 BollorĂ© telecom
 # See AUTHORS file for a full list of contributors.
 # 
 # This program is free software: you can redistribute it and/or modify
 
 from django.db.models import fields, SubfieldBase
 
+from ldapdb import escape_ldap_filter
+
 class CharField(fields.CharField):
     def __init__(self, *args, **kwargs):
         kwargs['max_length'] = 200
         super(CharField, self).__init__(*args, **kwargs)
 
-    def get_db_prep_value(self, value):
-        """Returns field's value prepared for interacting with the database
-        backend.
-
-        Used by the default implementations of ``get_db_prep_save``and
-        `get_db_prep_lookup```
-        """
-        return value.replace('\\', '\\5c') \
-                    .replace('*', '\\2a') \
-                    .replace('(', '\\28') \
-                    .replace(')', '\\29') \
-                    .replace('\0', '\\00')
-
+    def get_prep_lookup(self, lookup_type, value):
+        return escape_ldap_filter(value)
+        
 class ImageField(fields.Field):
     pass