oioioi.filetracker.fields

Module Contents

Classes

FieldFile

A mixin class used to forward file methods to an underlaying file

_FileDescriptor

The descriptor for the file attribute on the model instance. Return a

FileField

A FileField with fixtures support.

class oioioi.filetracker.fields.FieldFile(instance, field, name)[source]

Bases: django.db.models.fields.files.FieldFile

A mixin class used to forward file methods to an underlaying file object. The internal file object has to be called “file”:

class FileProxy(FileProxyMixin):
    def __init__(self, file):
        self.file = file
read_using_cache()[source]

Opens a file using a cache (if it’s possible)

class oioioi.filetracker.fields._FileDescriptor(field)[source]

Bases: django.db.models.fields.files.FileDescriptor

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
__get__(instance=None, owner=None)[source]

Retrieve and caches the value from the datastore on the first lookup. Return the cached value.

class oioioi.filetracker.fields.FileField(*args, **kwargs)[source]

Bases: django.db.models.fields.files.FileField

A FileField with fixtures support.

Default value of max_length is increased from 100 to 255.

Values of FileFields are serialized as:

data:<filename>:<base64-encoded data>

It is also possible to decode a more human-friendly representaion:

data:<filename>:raw:<raw data>

but this works only for ASCII content.

descriptor_class[source]
attr_class[source]
get_prep_value(value)[source]

Perform preliminary non-db specific value checks and conversions.

value_to_string(obj)[source]

Return a string value of this field from the passed obj. This is used by the serialization framework.