add some field definitions
authorjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 7 Sep 2009 09:32:01 +0000 (09:32 +0000)
committerjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 7 Sep 2009 09:32:01 +0000 (09:32 +0000)
git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@650 e071eeec-0327-468d-9b6a-08194a12b294

ldapdb/models/fields.py [new file with mode: 0644]

diff --git a/ldapdb/models/fields.py b/ldapdb/models/fields.py
new file mode 100644 (file)
index 0000000..78ec1c7
--- /dev/null
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+# 
+# django-ldapdb
+# Copyright (C) 2009 BollorĂ© telecom
+# See AUTHORS file for a full list of contributors.
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+from django.db.models import fields, SubfieldBase
+
+class CharField(fields.CharField):
+    def __init__(self, *args, **kwargs):
+        kwargs['max_length'] = 200
+        super(CharField, self).__init__(*args, **kwargs)
+
+class ImageField(fields.Field):
+    pass
+
+class IntegerField(fields.IntegerField):
+    pass
+
+class ListField(fields.Field):
+    __metaclass__ = SubfieldBase
+
+    def to_python(self, value):
+        if not value:
+            return []
+        return value
+