pyramid_basemodel - a thin, low level SQLAlchemy bindings to pyramid
pyramid_basemodel is a thin, low level package that provides an SQLAlchemy
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.
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
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
To run the tests use:
py.test -v --cov pyramid_basemodel tests/
- [package] Marked python 3.10 compatible (Trove Classifiers)
- [simplify] Removed
BaseSlugNameMixin.set_slugmethod. These parameters seemd like a way to override some core functionality, which seems like a rare enough case to not maintain it, especially without tests.
- [simplify] Removed
Blob.get_as_named_tempfileas it wasn't used.
- [simplify] Simplified the
Blob.update_from_url. Now the method accepts only url parameter and does exactly one thing.
- [code] Use default arguments instead of compose sections.
- [enhancement] Switch slugify to python-slugify as the latter is python3 compatible
- [enhancement] As far as existing tests are concerned, now there's both full compatibility and feature parity between python 2 and python 3
- [CI] use CI
Fix support for zope.sqlalchemy >= 1.2
Remove stray print statements.
Bump to remove
src/*.egg-info directory from PyPI distribution.
Make engine kwargs configurable.
basemodel.should_bind_engine config flag, which can be used,
e.g.: in ftests, to disable the automatic engine setup, even when application
False. This will break apps that rely on tables being created by default. However, it's much saner to only
explicitly told to, particularly as most applications will use migrations
to manage the database schema.
0.2.4 -> 0.2.6
Faff about horribly with the slug generation code.
KeyError syntax bug.
Support dotted path
util.get_object_id function and stamp
sqlalchemy.ext.declarative.declarative_base() subclasses with the
Fix Python3 support (requires 3.3 for the unicode literal character).
Allow concrete subclasses of
BaseModelContainer to be provided in the
tree.BaseContentRoot.mapping (as well as interfaces).
pyramid_basemodel.blob.Blob model class to store large binary files.
.slug module doctests. Fix ``install_requires
BaseMixin.class_name on a singularised version of the plural
class name. This may seem a bit arse about face, but allows us to use the
tablename to split the word, e.g.:
>>> class OperatingScale(Base, BaseMixin): ... __tablename__ 'operating_scales' ... >>> OperatingScale.class_name 'Operating Scale'
Just ignore all this if you don't plan on using the
BaseMixin.class_slug and base it and the
cls.__tablename__ instead of the
All still manually overrideable by providing the corresponding property with a
single underscore, e.g.:
Bugfix to parse config options properly.
basemodel.should_create_all configuration option.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for pyramid_basemodel-0.5.1-py2.py3-none-any.whl