Post«
Post (StorageAdapter)
«
Main Post class used to manage single post operations.
Attributes:
Name | Type | Description |
---|---|---|
storage_proxy |
StorageProxy |
Storage proxy used to communicate with storage backend. |
id |
int |
ID of the post. |
meta_data |
MetaData |
MetaData object holding all meta data values of the post. |
media_data |
MediaData |
MediaData object to manage all media data associated with the post. |
content |
dict |
JSON parsable content associated with the post |
media_index
property
readonly
«
Get media index JSON of all media data associated with the post.
__init__(self, storage_proxy, meta_data, content='')
special
«
Parameters:
Name | Type | Description | Default |
---|---|---|---|
storage_proxy |
StorageProxy |
Storage proxy used to communicate with storage system. |
required |
meta_data |
dict |
MetaData object associated with this post. content (dict, optional): JSON parsable object or string. |
required |
add_media(self, media_data, media_name, **kwargs)
«
Add media to be saved.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
media_data |
str |
Byte64 encoded string in DataURL format. |
required |
media_name |
str |
Name of media used to reference media bytes stored. |
required |
Returns:
Type | Description |
---|---|
None |
Nothing returned |
delete_media(self, media_name)
«
Delete media that is stored on disk.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
media_name |
str |
Name of media data to be deleted. |
required |
Returns:
Type | Description |
---|---|
None |
Nothing returned |
get_media(self, media_name, **kwargs)
«
Get bytes for media data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
media_name |
str |
Name of media data to be retrieved. |
required |
Returns:
Type | Description |
---|---|
str |
byte64 encoded str in DataURL format. |
remove_media(self, media_name)
«
Remove media that has not yet been saved to disk.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
media_name |
str |
Name of media data to remove. |
required |
Returns:
Type | Description |
---|---|
None |
Nothing returned |
save(self)
«
Save the post and all associated data.
Returns:
Type | Description |
---|---|
None |
Nothing returned |
to_json(self)
«
Get JSON representation of the post.
Returns:
Type | Description |
---|---|
dict |
JSON representation of the post. |
update_content(self, content)
«
Update content associated with the post.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content |
dict |
New content used to update old content. |
required |
Returns:
Type | Description |
---|---|
None |
Nothing returned |
update_meta_data(self, meta_dict)
«
Update meta data associated with the post.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
meta_dict |
dict |
New meta data used to update old meta data object. |
required |
Returns:
Type | Description |
---|---|
None |
Nothing returned |