Skip to main content

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()

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

.. code-block:: python

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyramid_basemodel-0.7.1.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyramid_basemodel-0.7.1-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file pyramid_basemodel-0.7.1.tar.gz.

File metadata

  • Download URL: pyramid_basemodel-0.7.1.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pyramid_basemodel-0.7.1.tar.gz
Algorithm Hash digest
SHA256 ac90ccfc2da53e3f84a99117c5cdd4adcbd1481532ae4771d7957d26d6a78ab1
MD5 a103e9b78ee75445613fec942da241c5
BLAKE2b-256 e10310fcf4e1db6aaf03d54c2bdbe176e45b0a44c9acbb31a1b1df9e8de10edd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyramid_basemodel-0.7.1.tar.gz:

Publisher: pypi.yml on fizyk/pyramid_basemodel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyramid_basemodel-0.7.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyramid_basemodel-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e98dd2a5254ebf3aa74577a31b8f643c6b3a2d37f9fc22d1ff002edacbe840a2
MD5 329fc32244d23cd615b08a9a25f24191
BLAKE2b-256 7b4cc4d376878c9cf1592365a69a9b1da5b8f345ff5a1f0b0043d0c771bf56b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyramid_basemodel-0.7.1-py3-none-any.whl:

Publisher: pypi.yml on fizyk/pyramid_basemodel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.7.1 This release

2 files

0.7.0

2 files

0.6.3

2 files

0.6.1

2 files

0.6.0

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

1 file

0.3.7

1 file

0.3.6

1 file

0.3.5

1 file

0.3.4

1 file

0.3.3

1 file

0.3.2

1 file

0.3.1

1 file

0.3

1 file

0.2.6

1 file

0.2.5

1 file

0.2.4

1 file

0.2.3

1 file

0.2.2

1 file

0.2.1

1 file

0.2

1 file

0.1.8

1 file

0.1.7

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1

1 file

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