Compare commits
No commits in common. "3a1ea22e9b0daf526626a61657c3e26014d069b8" and "028c64fc12640387581c877e13705f77e284dbcd" have entirely different histories.
3a1ea22e9b
...
028c64fc12
|
@ -5,15 +5,6 @@ All notable changes to WuttJamaican will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## v0.16.1 (2024-12-05)
|
|
||||||
|
|
||||||
### Fix
|
|
||||||
|
|
||||||
- add `db.util.make_topo_sortkey()` function
|
|
||||||
- use true UUID type for Upgrades table primary key
|
|
||||||
- let caller set data type for `uuid_column()` and `uuid_fk_column()`
|
|
||||||
- avoid error when loading installer templates
|
|
||||||
|
|
||||||
## v0.16.0 (2024-11-30)
|
## v0.16.0 (2024-11-30)
|
||||||
|
|
||||||
### Feat
|
### Feat
|
||||||
|
|
|
@ -22,39 +22,35 @@ Make a parent folder for all source code:
|
||||||
|
|
||||||
mkdir -p ~/src
|
mkdir -p ~/src
|
||||||
|
|
||||||
Make and activate a new :term:`virtual environment` for your project:
|
Make a :term:`virtual environment` for your project:
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
cd /path/to/envs
|
cd /path/to/envs
|
||||||
python3 -m venv poser
|
python3 -m venv poser
|
||||||
source poser/bin/activate
|
|
||||||
|
|
||||||
Make a new e.g. ``poser`` database in PostgreSQL (or MySQL).
|
Make a new e.g. ``poser`` database in PostgreSQL (or MySQL).
|
||||||
|
|
||||||
Install and run `cookiecutter <https://cookiecutter.readthedocs.io/>`_
|
Install and run cookiecutter with wuttaweb template:
|
||||||
with `wuttaweb template
|
|
||||||
<https://forgejo.wuttaproject.org/wutta/cookiecutter-wuttaweb>`_:
|
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
pip install cookiecutter
|
cd /path/to/envs/poser
|
||||||
cookiecutter -o ~/src git+https://forgejo.wuttaproject.org/wutta/cookiecutter-wuttaweb
|
bin/pip install cookiecutter
|
||||||
|
bin/cookiecutter -o ~/src git+https://forgejo.wuttaproject.org/wutta/cookiecutter-wuttaweb
|
||||||
|
|
||||||
Assuming you now have project code at ``~/src/poser`` then install
|
Assuming you now have project code at ``~/src/poser`` then install
|
||||||
that and run the app installer. Note the 2nd command name will depend
|
that and run the app installer:
|
||||||
on your project:
|
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
pip install -e ~/src/poser
|
bin/pip install -e ~/src/poser
|
||||||
poser install
|
bin/poser install
|
||||||
|
|
||||||
If all goes well, you can run the web app with:
|
If all goes well, you can run the web app with:
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
cd /path/to/envs/poser
|
|
||||||
bin/pserve --reload file+ini:app/web.conf
|
bin/pserve --reload file+ini:app/web.conf
|
||||||
|
|
||||||
And browse it at http://localhost:9080
|
And browse it at http://localhost:9080
|
||||||
|
|
|
@ -6,10 +6,10 @@ build-backend = "hatchling.build"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "WuttJamaican"
|
name = "WuttJamaican"
|
||||||
version = "0.16.1"
|
version = "0.16.0"
|
||||||
description = "Base package for Wutta Framework"
|
description = "Base package for Wutta Framework"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = [{name = "Lance Edgar", email = "lance@wuttaproject.org"}]
|
authors = [{name = "Lance Edgar", email = "lance@edbob.org"}]
|
||||||
license = {text = "GNU GPL v3+"}
|
license = {text = "GNU GPL v3+"}
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Development Status :: 4 - Beta",
|
"Development Status :: 4 - Beta",
|
||||||
|
@ -49,7 +49,6 @@ wutta = "wuttjamaican.cli:wutta_typer"
|
||||||
[project.urls]
|
[project.urls]
|
||||||
Homepage = "https://wuttaproject.org/"
|
Homepage = "https://wuttaproject.org/"
|
||||||
Repository = "https://forgejo.wuttaproject.org/wutta/wuttjamaican"
|
Repository = "https://forgejo.wuttaproject.org/wutta/wuttjamaican"
|
||||||
Issues = "https://forgejo.wuttaproject.org/wutta/wuttjamaican/issues"
|
|
||||||
Changelog = "https://forgejo.wuttaproject.org/wutta/wuttjamaican/src/branch/master/CHANGELOG.md"
|
Changelog = "https://forgejo.wuttaproject.org/wutta/wuttjamaican/src/branch/master/CHANGELOG.md"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ Database Utilities
|
||||||
import uuid as _uuid
|
import uuid as _uuid
|
||||||
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy import orm
|
|
||||||
from sqlalchemy.dialects.postgresql import UUID as PGUUID
|
from sqlalchemy.dialects.postgresql import UUID as PGUUID
|
||||||
|
|
||||||
from wuttjamaican.util import make_uuid
|
from wuttjamaican.util import make_uuid
|
||||||
|
@ -128,26 +127,3 @@ def uuid_fk_column(target_column, *args, **kwargs):
|
||||||
if not args:
|
if not args:
|
||||||
args = (sa.String(length=32), sa.ForeignKey(target_column))
|
args = (sa.String(length=32), sa.ForeignKey(target_column))
|
||||||
return sa.Column(*args, **kwargs)
|
return sa.Column(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def make_topo_sortkey(model):
|
|
||||||
"""
|
|
||||||
Returns a function suitable for use as a ``key`` kwarg to a
|
|
||||||
standard Python sorting call. This key function will expect a
|
|
||||||
single class mapper and return a sequence number associated with
|
|
||||||
that model. The sequence is determined by SQLAlchemy's
|
|
||||||
topological table sorting.
|
|
||||||
|
|
||||||
:param model: Usually the :term:`app model`, but can be any module
|
|
||||||
containing model classes.
|
|
||||||
"""
|
|
||||||
metadata = model.Base.metadata
|
|
||||||
tables = dict([(table.name, i)
|
|
||||||
for i, table in enumerate(metadata.sorted_tables, 1)])
|
|
||||||
|
|
||||||
def sortkey(name):
|
|
||||||
cls = getattr(model, name)
|
|
||||||
mapper = orm.class_mapper(cls)
|
|
||||||
return tuple(tables[t.name] for t in mapper.tables)
|
|
||||||
|
|
||||||
return sortkey
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ try:
|
||||||
from wuttjamaican.db import util as mod
|
from wuttjamaican.db import util as mod
|
||||||
from wuttjamaican.db.model.base import Setting
|
from wuttjamaican.db.model.base import Setting
|
||||||
from wuttjamaican.util import make_true_uuid
|
from wuttjamaican.util import make_true_uuid
|
||||||
from wuttjamaican.testing import DataTestCase
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -125,17 +124,3 @@ else:
|
||||||
self.assertIsInstance(column, sa.Column)
|
self.assertIsInstance(column, sa.Column)
|
||||||
self.assertIsInstance(column.type, sa.String)
|
self.assertIsInstance(column.type, sa.String)
|
||||||
self.assertEqual(column.type.length, 32)
|
self.assertEqual(column.type.length, 32)
|
||||||
|
|
||||||
|
|
||||||
class TestMakeTopoSortkey(DataTestCase):
|
|
||||||
|
|
||||||
def test_basic(self):
|
|
||||||
model = self.app.model
|
|
||||||
sortkey = mod.make_topo_sortkey(model)
|
|
||||||
original = ['User', 'Person', 'UserRole', 'Role']
|
|
||||||
|
|
||||||
# models are sorted so dependants come later
|
|
||||||
result = sorted(original, key=sortkey)
|
|
||||||
self.assertTrue(result.index('Role') < result.index('UserRole'))
|
|
||||||
self.assertTrue(result.index('User') < result.index('UserRole'))
|
|
||||||
self.assertTrue(result.index('Person') < result.index('User'))
|
|
||||||
|
|
Loading…
Reference in a new issue