class documentation

class MediaDb(OFS.SimpleItem.Item, Persistent, Acquisition.Implicit): (source)

Constructor: MediaDb(location, structure)

View In Hierarchy

Persistent Zope object that stores uploaded binary assets in a flat or hierarchical filesystem.

The MediaDb provides methods to store and retrieve files, compute target paths, and manage the storage structure. The mediadb is designed to be attached to a ZMS content object as a child with a fixed id (acl_mediadb) and accessed via the getMediaDb() method. The mediadb location is configurable and supports expansion of $INSTANCE_HOME. The mediadb also provides management interface methods to serve files as HTTP responses and to reorganize the storage structure.

Method __init__ Initialize the instance state.
Method getFile Stream the file identified by the request path as an HTTP response.
Method getFileSize Return the size in bytes of the given mediadb file.
Method getLocation Return the resolved filesystem root path, expanding $INSTANCE_HOME.
Method getParentDir Return the parent directory of the given filesystem path.
Method getPath Return the requested filesystem path, defaulting to the mediadb root.
Method getStructure Return the directory nesting depth used for hierarchical storage (0 = flat).
Method manage_changeProperties Apply submitted form changes to MediaDb location and redirect back to properties.
Method manage_index_html Serve a mediadb file as a streaming HTTP response.
Method manage_test Scan the mediadb and return a JSON report of OK/MISSING file statuses.
Method readDir Return a directory listing for the given filesystem path.
Method retrieveFile Return the raw bytes of the given mediadb file.
Method retrieveFileStreamIterator Retrieve a mediadb file and return its content as a stream or bytes object.
Method setLocation Set the filesystem root path for the mediadb, stripping any trailing slash.
Method storeFile Store an uploaded file object into the mediadb and return its unique filename.
Method targetFile Compute the full filesystem path where a file should be stored.
Method urlQuote Return the URL-encoded form of the given string.
Method valid_filenames Return a list of (attr_path, filename) pairs for all mediadb-referenced files.
Class Variable manage_browse Undocumented
Class Variable manage_main Undocumented
Class Variable manage_options Undocumented
Class Variable manage_properties Undocumented
Class Variable meta_type Undocumented
Class Variable security Undocumented
Class Variable zmi_icon Undocumented
Instance Variable id Undocumented
Instance Variable location Undocumented
Instance Variable structure Undocumented
def __init__(self, location, structure=0): (source)

Initialize the instance state.

def getFile(self, REQUEST, RESPONSE): (source)

Stream the file identified by the request path as an HTTP response.

def getFileSize(self, filename): (source)

Return the size in bytes of the given mediadb file.

def getLocation(self): (source)

Return the resolved filesystem root path, expanding $INSTANCE_HOME.

def getParentDir(self, path): (source)

Return the parent directory of the given filesystem path.

def getPath(self, REQUEST): (source)

Return the requested filesystem path, defaulting to the mediadb root.

def getStructure(self): (source)

Return the directory nesting depth used for hierarchical storage (0 = flat).

def manage_changeProperties(self, submit, REQUEST, RESPONSE): (source)

Apply submitted form changes to MediaDb location and redirect back to properties.

def manage_index_html(self, filename, REQUEST=None): (source)

Serve a mediadb file as a streaming HTTP response.

def manage_test(self, REQUEST, RESPONSE): (source)

Scan the mediadb and return a JSON report of OK/MISSING file statuses.

def readDir(self, path): (source)

Return a directory listing for the given filesystem path.

def retrieveFile(self, filename): (source)

Return the raw bytes of the given mediadb file.

def retrieveFileStreamIterator(self, filename, REQUEST=None): (source)

Retrieve a mediadb file and return its content as a stream or bytes object.

def setLocation(self, location): (source)

Set the filesystem root path for the mediadb, stripping any trailing slash.

def storeFile(self, file): (source)

Store an uploaded file object into the mediadb and return its unique filename.

def targetFile(self, filename): (source)

Compute the full filesystem path where a file should be stored.

def urlQuote(self, s): (source)

Return the URL-encoded form of the given string.

def valid_filenames(self): (source)

Return a list of (attr_path, filename) pairs for all mediadb-referenced files.

manage_browse = (source)

Undocumented

manage_main = (source)

Undocumented

manage_options: tuple = (source)

Undocumented

manage_properties = (source)

Undocumented

meta_type: str = (source)

Undocumented

security = (source)

Undocumented

zmi_icon: str = (source)

Undocumented

Undocumented

location = (source)

Undocumented

structure = (source)

Undocumented