Pytigon's schfs (SCH File System) abstracts file storage behind a uniform interface. Whether your files live on disk, in the database, in memory, or on a remote server, your application code treats them the same way.
In a multi-deployment system where the same application may run as a desktop app (with files on disk), a web server (with files in cloud storage), or a hybrid (with files split between local and remote), hard-coding file paths is a recipe for deployment pain. schfs solves this by:
vfstools.VfsDisk)Files stored on the local filesystem. Used by desktop applications and development servers.
from pytigon_lib.schfs.vfstools import VfsDisk
vfs = VfsDisk("/path/to/storage/root")
vfs.open("documents/report.pdf", "rb")
vfstools.VfsDatabase)Files stored as BLOB fields in a database table. Used when files need to be included in database backups or when multiple servers share a database.
vfstools.VfsMemory)Files stored in RAM. Used for temporary files and testing.
vfstools.VfsRemote)Files stored on a remote server accessed via HTTP.
All backends support the same operations:
# Open a file
with vfs.open("path/to/file.txt", "r") as f:
content = f.read()
# Write a file
with vfs.open("path/to/new_file.txt", "w") as f:
f.write("Hello, virtual world!")
# List directory contents
files = vfs.listdir("path/to/directory/")
# Check if file exists
if vfs.exists("path/to/file.txt"):
...
# Get file metadata
info = vfs.stat("path/to/file.txt")
# info.size, info.modified_time, info.is_directory
# Delete a file
vfs.delete("path/to/file.txt")
# Create a directory
vfs.mkdir("path/to/new_directory/")
Virtual filesystem paths look like regular filesystem paths but use forward slashes:
/documents/reports/2025/summary.pdf
/images/logos/company.png
/templates/custom/header.ihtml
The root path depends on the backend configuration. Multi-tenant deployments can use different storage roots per tenant.
Configure the virtual filesystem in settings_app.py:
VFS_BACKEND = 'disk' # or 'database', 'memory', 'remote'
VFS_ROOT = '/var/data/pytigon'
VFS_CACHE_ENABLED = True
VFS_CACHE_SIZE_MB = 256
schfs includes task support for file operations that should happen asynchronously — large file imports, batch processing, remote synchronization.