Skip to main content
Navigation
HomeTechnical ReferenceJournalGitHubGitHub
Sidebar — toggle document categories via the logo
PostManager — Python Library for Blog Post & Media Management

PostManager — Python Library for Blog Post & Media Management

July 17, 2023

Overview

PostManager (postmanager) is a Python library that abstracts post and media management behind a clean, storage-agnostic interface. Whether you're building a blog engine, a photo gallery, or a personal knowledge base, PostManager provides a unified API for creating, reading, updating, and deleting posts — each containing flexible metadata, markdown content, and base64-encoded media attachments.

The library uses an adapter/proxy pattern to decouple domain objects from where data is stored. Out of the box, it supports local filesystem storage (via pathlib) and AWS S3 storage (via boto3), and new backends can be added by implementing the StorageInterface abstract base class. It is published on PyPI (v0.1.6) and comes with comprehensive MkDocs documentation and a full CI/CD pipeline.


Key Features

  • Pluggable storage backends: Local filesystem (~/.postmanager/data/) and AWS S3 — switch with a single factory method call
  • Flexible metadata: MetaData objects accept arbitrary key-value pairs via dynamic setattr(), with JSON serialization and incremental update support
  • Media management: Base64-encoded media in Data URL format (compatible with the FileReader API), buffered save/delete, and media_index.json file mapping
  • Auto-incrementing IDs: PostManager tracks a latest_id.json for collision-free post identifiers
  • Full CRUD for posts: Create, get by ID, get by title, save, delete, and list all posts with content and media
  • PyPI distribution: Published package installable via pip install postmanager
  • Automated CI/CD: GitHub Actions for tests, coverage (Codecov), linting (mypy + flake8), docs build/deploy, and PyPI release on version tags
  • Comprehensive docs: MkDocs Material site with code-level API documentation via mkdocstrings

Architecture

A clean adapter/proxy architecture separating domain objects from storage:

PostManager
Post
MetaData ─── all extend ───▶ StorageAdapter
MediaData │

delegates to


StorageProxy (abstract)
╱ ╲
╱ ╲
StorageProxyLocal StorageProxyS3
(pathlib) (boto3 S3)
ComponentRole
StorageInterfaceAbstract base class — get_json, save_json, save_bytes, get_bytes, delete_file, list_files
StorageProxyAbstract bridge holding root_dir + client, extended by concrete implementations
StorageAdapterBase class all domain objects extend; delegates to a StorageProxy; provides new_storage_proxy() for scoped child operations
PostManagerRoot orchestrator managing an index of all posts
PostSingle post — contains MetaData + MediaData + content
MetaDataDynamic attribute bag with JSON serialization
MediaDataBase64 Data URL media manager with buffered operations

Tech Stack

LayerTechnology
LanguagePython 3.9+
Package mgmtsetuptools, setup.cfg
Cloud storageAWS S3 via boto3
Local storagepathlib.Path
Type checkingmypy (strict mode), flake8
Testingpytest, coverage (Codecov)
DocsMkDocs Material, mkdocstrings (Google-style)
CI/CDGitHub Actions (6 workflows)
DistributionPyPI (v0.1.6)
LicenseMIT