pyramid-basemodel


Namepyramid-basemodel JSON
Version 0.6.1 PyPI version JSON
download
home_page
Summarypyramid_basemodel - a thin, low level SQLAlchemy bindings to pyramid
upload_time2023-10-11 16:19:41
maintainer
docs_urlNone
authorJames Arthur
requires_python>=3.8
licenseThis is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to <http://unlicense.org/>
keywords pyramid sqlalchemy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            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.:

.. code-block:: python

    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.:

.. code-block:: python

    # 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:

.. code-block::

    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

Release
=======

Install pipenv and --dev dependencies first, Then run:

.. code-block::

    pipenv run tbump [NEW_VERSION]

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pyramid-basemodel",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Grzegorz \u015aliwi\u0144ski <fizyk+pypi@fizyk.dev>",
    "keywords": "pyramid,sqlalchemy",
    "author": "James Arthur",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/f4/be/744216b59b2afcb58be66d4ad1b1c00a268745d498af2a23040a12d72ef1/pyramid_basemodel-0.6.1.tar.gz",
    "platform": null,
    "description": "pyramid_basemodel\n=================\n\n**pyramid_basemodel** is a thin, low level package that provides an SQLAlchemy\ndeclarative `Base` and a thread local scoped `Session` that can be used by\ndifferent packages whilst only needing to be bound to a db engine once.\n\nUsage\n-----\n\nYou can use these as base classes for declarative model definitions, e.g.:\n\n.. code-block:: python\n\n    from pyramid_basemodel import Base, BaseMixin, Session, save\n\n    class MyModel(Base, BaseMixin):\n        \"\"\"Example model class.\"\"\"\n\n        @classmethod\n        def do_foo(cls):\n            instance = Session.query(cls).first()\n            save(instance)\n\n\nYou can then bind these to the `sqlalchemy.url` in your paster `.ini` config by\nimporting your model and this package, e.g.:\n\n.. code-block:: python\n\n    # for example in yourapp.__init__.py\n    import mymodel\n    \n    def main(global_config, **settings):\n        config = Configurator(settings=settings)\n        config.include('pyramid_basemodel')\n        config.include('pyramid_tm')\n        return config.make_wsgi_app()\n\nOr if this is all too much voodoo, you can just use the `bind_engine` function::\n\n.. code-block:: python\n\n    from pyramid_basemodel import bind_engine\n    from mypackage import mymodel\n\n    # assuming `engine` is a bound SQLAlchemy engine.\n    bind_engine(engine)\n\nNote that the `Session` is designed to be used in tandem with [pyramid_tm][].\nIf you don't include `pyramid_tm`, you'll need to take care of committing\ntransactions yourself.\n\nTests\n-----\n\nTo run the tests use:\n\n.. code-block::\n\n    py.test -v --cov pyramid_basemodel tests/\n\n[pyramid_basemodel]: http://github.com/fizyk/pyramid_basemodel\n[pyramid_simpleauth]: http://github.com/thruflo/pyramid_simpleauth\n[pyramid_tm]: http://pyramid_tm.readthedocs.org\n\nRelease\n=======\n\nInstall pipenv and --dev dependencies first, Then run:\n\n.. code-block::\n\n    pipenv run tbump [NEW_VERSION]\n",
    "bugtrack_url": null,
    "license": "This is free and unencumbered software released into the public domain.  Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.  In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  For more information, please refer to <http://unlicense.org/> ",
    "summary": "pyramid_basemodel - a thin, low level SQLAlchemy bindings to pyramid",
    "version": "0.6.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/fizyk/pyramid_basemodel/issues",
        "Changelog": "https://github.com/fizyk/pyramid_basemodel/blob/v0.6.1/CHANGES.rst",
        "Source": "https://github.com/fizyk/pyramid_basemodel/"
    },
    "split_keywords": [
        "pyramid",
        "sqlalchemy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b53a96b879acc8b3048617d6cb20decbb81f011a04ce6acb76cca61210138ca1",
                "md5": "fcf20dd527ded0e1b9de63b04eb27756",
                "sha256": "04804e313f62d391d39d93bba2068beae9d5ca6bf20d4a692fee737c9ebbf485"
            },
            "downloads": -1,
            "filename": "pyramid_basemodel-0.6.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fcf20dd527ded0e1b9de63b04eb27756",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 15041,
            "upload_time": "2023-10-11T16:19:40",
            "upload_time_iso_8601": "2023-10-11T16:19:40.421719Z",
            "url": "https://files.pythonhosted.org/packages/b5/3a/96b879acc8b3048617d6cb20decbb81f011a04ce6acb76cca61210138ca1/pyramid_basemodel-0.6.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f4be744216b59b2afcb58be66d4ad1b1c00a268745d498af2a23040a12d72ef1",
                "md5": "f5c7033288676821c87ffb54e6d51058",
                "sha256": "108c235ea642e49c52181548cccae13160fb977811b0cdac99aa03ccbe7bf591"
            },
            "downloads": -1,
            "filename": "pyramid_basemodel-0.6.1.tar.gz",
            "has_sig": false,
            "md5_digest": "f5c7033288676821c87ffb54e6d51058",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 17561,
            "upload_time": "2023-10-11T16:19:41",
            "upload_time_iso_8601": "2023-10-11T16:19:41.729508Z",
            "url": "https://files.pythonhosted.org/packages/f4/be/744216b59b2afcb58be66d4ad1b1c00a268745d498af2a23040a12d72ef1/pyramid_basemodel-0.6.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-11 16:19:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fizyk",
    "github_project": "pyramid_basemodel",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "pyramid-basemodel"
}
        
Elapsed time: 0.12120s