module documentation

_blobfields.py - Blob, Image, and File Field Management for ZMS

Blob fields are content attributes that store binary data (images, documents) within ZMS objects. This module provides the foundational classes and utilities for the entire blob field subsystem, enabling seamless integration of file uploads, secure access control, efficient HTTP delivery, and flexible storage backends.

License: GNU General Public License v2 or later, Organization: ZMS Publishing

Class MyBlob Base class for binary large objects (blobs) stored in ZMS.
Class MyBlobDelegate Simple delegate wrapper for blob objects.
Class MyBlobWrapper Wrapper for external Zope file objects to provide blob-like interface.
Class MyFile ZMS file blob class for managing binary and text files.
Class MyImage ZMS image blob class for managing image files with metadata.
Function bytes_hex Convert binary or text data to a hexadecimal string.
Function createBlobField Create a blob field instance and initialize it from uploaded data.
Function getLangFilename Append a language suffix to a filename when needed.
Function recurse_downloadRessources Export blob resources from the ZODB to the filesystem.
Function rfc1123_date Format a UNIX timestamp as an RFC 1123 HTTP date.
Function thumbnailImage Generate a thumbnail image from one image attribute into another.
Function thumbnailImageFields Generate configured thumbnail variants for all image fields.
Function uploadBlobField Build a blob field from raw uploaded content.
def bytes_hex(data): (source)

Convert binary or text data to a hexadecimal string.

Parameters
data:bytes or strInput data
Returns
strHexadecimal representation
def createBlobField(self, objtype, file=b''): (source)

Create a blob field instance and initialize it from uploaded data.

Parameters
selfZMS context object
objtype:strDesired blob type
file:bytes, file-like, or dictUploaded file data or metadata dictionary
Returns
MyImage or MyFileCreated blob object
def getLangFilename(self, filename, lang): (source)

Append a language suffix to a filename when needed.

Parameters
selfZMS context object
filename:strOriginal filename
lang:strLanguage identifier
Returns
strLanguage-aware filename
def recurse_downloadRessources(self, base_path, REQUEST): (source)

Export blob resources from the ZODB to the filesystem.

Parameters
selfZMS context object
base_path:strExport base path
REQUESTZope request object
Returns
listExported resource metadata entries
def rfc1123_date(dt): (source)

Format a UNIX timestamp as an RFC 1123 HTTP date.

Parameters
dt:float or intTimestamp value
Returns
strRFC 1123 formatted date string
def thumbnailImage(self, hiresKey, loresKey, maxdim, lang, REQUEST): (source)

Generate a thumbnail image from one image attribute into another.

Parameters
selfZMS context object
hiresKey:strSource image attribute id
loresKey:strTarget image attribute id
maxdim:intMaximum thumbnail dimension
lang:strLanguage identifier
REQUESTZope request object
Returns
strStatus message
def thumbnailImageFields(self, lang, REQUEST): (source)

Generate configured thumbnail variants for all image fields.

Parameters
selfZMS context object
lang:strLanguage identifier
REQUESTZope request object
Returns
strStatus message
def uploadBlobField(self, clazz, file=b'', filename=''): (source)

Build a blob field from raw uploaded content.

Parameters
selfZMS context object
clazzRequested blob datatype or class
file:bytes, str, or file-likeUploaded file content
filename:strOriginal filename
Returns
MyImage or MyFileInitialized blob object