File: compat.py

package info (click to toggle)
django-recurrence 1.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,148 kB
  • sloc: python: 2,530; javascript: 2,502; makefile: 159; sh: 6
file content (21 lines) | stat: -rw-r--r-- 640 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
try:
    from django.db.models.fields.subclassing import Creator
except ImportError:
    # This class was removed in Django 1.10, so I've pulled it into
    # django-recurrence.

    class Creator:
        """
        A placeholder class that provides a way to set the attribute
        on the model.
        """
        def __init__(self, field):
            self.field = field

        def __get__(self, obj, type=None):
            if obj is None:
                return self
            return obj.__dict__[self.field.name]

        def __set__(self, obj, value):
            obj.__dict__[self.field.name] = self.field.to_python(value)