Skip to main content

pyramid_basemodel

pyramid_basemodel is a thin, low level package that provides an SQLAlchemy declarative Base and a thread local scoped Session that can be used by different packages whilst only needing to be bound to a db engine once.

Usage

You can use these as base classes for declarative model definitions, e.g.:

from pyramid_basemodel import Base, BaseMixin, Session, save

class MyModel(Base, BaseMixin):
    """Example model class."""

    @classmethod
    def do_foo(cls):
        instance = Session.query(cls).first()
        save(instance)

You can then bind these to the sqlalchemy.url in your paster .ini config by importing your model and this package, e.g.:

# for example in yourapp.__init__.py
import mymodel

def main(global_config, **settings):
    config = Configurator(settings=settings)
    config.include('pyramid_basemodel')
    config.include('pyramid_tm')
    return config.make_wsgi_app()

To pass extra keyword arguments to SQLAlchemy’s engine_from_config, point the sqlalchemy.engine_kwargs_factory setting at a callable by its dotted name:

[app:main]
sqlalchemy.url = postgresql://localhost/mydb
sqlalchemy.engine_kwargs_factory = yourapp.db:engine_kwargs

The callable receives the application registry and returns a dictionary of keyword arguments, e.g.:

# for example in yourapp/db.py
def engine_kwargs(registry):
    return {"connect_args": {"application_name": "yourapp"}}

Use it for arguments that a paster .ini value cannot express, such as objects or nested dictionaries. If the sqlalchemy.pool_class setting is also given, it overrides any poolclass the factory returns.

Or if this is all too much voodoo, you can just use the bind_engine function:

from pyramid_basemodel import bind_engine
from mypackage import mymodel

# assuming `engine` is a bound SQLAlchemy engine.
bind_engine(engine)

Note that the Session is designed to be used in tandem with [pyramid_tm][]. If you don’t include pyramid_tm, you’ll need to take care of committing transactions yourself.

Tests

To run the tests use:

py.test -v --cov pyramid_basemodel tests/

[pyramid_basemodel]: http://github.com/fizyk/pyramid_basemodel [pyramid_simpleauth]: http://github.com/thruflo/pyramid_simpleauth [pyramid_tm]: http://pyramid_tm.readthedocs.org

Metadata

Release files for pyramid-basemodel 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyramid-basemodel 1.1.0
File Size Uploaded Provenance Actions
pyramid_basemodel-1.1.0.tar.gz 17.4 kB With provenance Details for pyramid_basemodel-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyramid-basemodel 1.1.0
File Interpreter ABI Platform Actions
pyramid_basemodel-1.1.0-py3-none-any.whl Python 3 none any Details for pyramid_basemodel-1.1.0-py3-none-any.whl

Total release size: 34.7 kB

Release files / pyramid_basemodel-1.1.0.tar.gz

Download URL pyramid_basemodel-1.1.0.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6a725610b650571d577af1b015a2c9201080a2c0a8597a24cde87e6c7a0438b8
BLAKE2b-256 checksum
How to use checksums
4ffff9cbfc845258d718575a134f0084d3008c9c086788d5173f34859bcc39e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / pyramid_basemodel-1.1.0-py3-none-any.whl

Download URL pyramid_basemodel-1.1.0-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d0291405e471e85b0ea7d92cc9727c628ab737d04ee0493ba90ce6d35a13afd8
BLAKE2b-256 checksum
How to use checksums
56c3e577d7473956196b6682b86e083c6efc0e5ac3b852172f37c63830c44538
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for pyramid-basemodel 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyramid_basemodel-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page