From: jlaine Date: Mon, 7 Sep 2009 09:32:01 +0000 (+0000) Subject: add some field definitions X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fdjango-ldapdb.git;a=commitdiff_plain;h=5d6d80bf9769f442c2cb646a8b2932c44aa6bce0 add some field definitions git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@650 e071eeec-0327-468d-9b6a-08194a12b294 --- diff --git a/ldapdb/models/fields.py b/ldapdb/models/fields.py new file mode 100644 index 0000000..78ec1c7 --- /dev/null +++ b/ldapdb/models/fields.py @@ -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 . +# + +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 +