Forum attachments¶
The forum_attachments
application handles all the attachments that can be associated with forum posts.
Abstract models¶
-
class
machina.apps.forum_conversation.forum_attachments.abstract_models.
AbstractAttachment
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Represents a post attachment. An attachment is always linked to a post.
Cache¶
-
class
machina.apps.forum_conversation.forum_attachments.cache.
AttachmentCache
¶ Bases:
object
The attachments cache. This one should be used with a FileBasedCache backend. But this can be overriden. The attachments cache acts as a wrapper and ensure that the states (name, size, content type, charset and content) of all files from any request.FILES dict are saved inside the considered backend when calling the ‘set’ method. Conversely, the ‘get’ method will populate a dictionary of InMemoryUploadedFile instances or TemporaryUploadedFile instancesby using these states.
-
get
(key)¶ Regenerates a MultiValueDict instance containing the files related to all file states stored for the given key.
-
set
(key, files)¶ Stores the state of each file embedded in the request.FILES MultiValueDict instance. This instance is assumed to be passed as the ‘files’ argument. Each state stored in the cache is a dictionary containing the following values:
- name
- The name of the uploaded file.
- size
- The size of the uploaded file.
- content_type
- The content type of the uploaded file.
- content_length
- The content length of the uploaded file.
- charset
- The charset of the uploaded file.
- content
- The content of the uploaded file.
-