Compare commits

...

13 commits

Author SHA1 Message Date
Lance Edgar 87d84f005a build: add release task 2024-11-24 10:35:20 -06:00
Lance Edgar 86abdea9d7 bump: version 0.2.3 → 0.2.4 2024-11-24 10:33:08 -06:00
Lance Edgar 8946121e8a fix: update project links, kallithea -> forgejo 2024-09-14 13:19:35 -05:00
Lance Edgar 59e61357be docs: use markdown for readme file 2024-09-13 18:42:05 -05:00
Lance Edgar f18037b2fb fix: avoid deprecated base class for config extension 2024-08-16 10:14:33 -05:00
Lance Edgar beddcf6987 fix: just use upstream main() for webapi
apparently this demo is not customizing anything and had some old code
which no longer works (auth policy)
2024-07-18 09:37:28 -05:00
Lance Edgar c67494a18c fix: update menu config per wuttaweb 2024-07-14 11:37:36 -05:00
Lance Edgar e10b1fa2fd fix: update config for default app model
per rattail changes
2024-07-13 09:36:40 -05:00
Lance Edgar 19f4f62229 fix: remove unused alembic script
we just use the upstream script now
2024-07-02 09:44:15 -05:00
Lance Edgar 6756899bbb bump: version 0.2.2 → 0.2.3 2024-07-01 11:54:15 -05:00
Lance Edgar cbb5174ac8 fix: use rattail function to create top-level command
share code in case logic ever changes
2024-07-01 11:54:04 -05:00
Lance Edgar 10e79be01a bump: version 0.2.1 → 0.2.2 2024-06-30 12:00:10 -05:00
Lance Edgar e071a9ba25 fix: declare custom static libcache module for tailbone
whoops, missed this in last commit
2024-06-30 11:59:45 -05:00
10 changed files with 71 additions and 137 deletions

View file

@ -5,6 +5,29 @@ All notable changes to rattail will be documented in this file.
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).
## v0.2.4 (2024-11-24)
### Fix
- update project links, kallithea -> forgejo
- avoid deprecated base class for config extension
- just use upstream `main()` for webapi
- update menu config per wuttaweb
- update config for default app model
- remove unused alembic script
## v0.2.3 (2024-07-01)
### Fix
- use rattail function to create top-level command
## v0.2.2 (2024-06-30)
### Fix
- declare custom static libcache module for tailbone
## v0.2.1 (2024-06-30)
### Fix

View file

@ -1,11 +1,9 @@
Rattail Demo
============
# Rattail Demo
This project serves as a working demo, to illustrate various concepts of the
Rattail software framework. See the `Rattail Wiki`_ for more info.
This project serves as a working demo, to illustrate various concepts
of the Rattail software framework. See the [Rattail
Wiki](https://rattailproject.org/moin/) for more info.
Note that it *can be* usable as a starting point for your own project(s),
should you need one. But probably the Rattail Tutorial is a better one.
.. _`Rattail Wiki`: https://rattailproject.org/moin/

View file

@ -6,9 +6,9 @@ build-backend = "hatchling.build"
[project]
name = "rattail-demo"
version = "0.2.1"
version = "0.2.4"
description = "Rattail Software Demo"
readme = "README.rst"
readme = "README.md"
authors = [{name = "Lance Edgar", email = "lance@edbob.org"}]
classifiers = [
"Development Status :: 3 - Alpha",
@ -51,8 +51,8 @@ rattail-demo = "rattail_demo.config:DemoConfigExtension"
[project.urls]
Homepage = "https://demo.rattailproject.org"
Repository = "https://kallithea.rattailproject.org/rattail-project/rattail-demo"
Changelog = "https://kallithea.rattailproject.org/rattail-project/rattail-demo/files/master/CHANGELOG.md"
Repository = "https://forgejo.wuttaproject.org/rattail/rattail-demo"
Changelog = "https://forgejo.wuttaproject.org/rattail/rattail-demo/src/branch/master/CHANGELOG.md"
[tool.commitizen]

View file

@ -11,7 +11,7 @@ import shutil
import typer
from typing_extensions import Annotated
from rattail.commands.typer import (typer_callback, typer_get_runas_user,
from rattail.commands.typer import (make_typer, typer_get_runas_user,
importer_command, file_exporter_command)
from rattail.commands.importing import ImportCommandHandler
from rattail.commands.purging import run_purge
@ -19,9 +19,9 @@ from rattail.commands.purging import run_purge
log = logging.getLogger(__name__)
# nb. this is the top-level command for titeship
rattail_demo_typer = typer.Typer(
callback=typer_callback,
# nb. this is the top-level command
rattail_demo_typer = make_typer(
name='rattail_demo',
help="Rattail Demo (custom Rattail system)"
)

View file

@ -3,10 +3,10 @@
Rattail Demo config extension
"""
from rattail.config import ConfigExtension
from wuttjamaican.conf import WuttaConfigExtension
class DemoConfigExtension(ConfigExtension):
class DemoConfigExtension(WuttaConfigExtension):
"""
Rattail Demo config extension
"""
@ -17,9 +17,12 @@ class DemoConfigExtension(ConfigExtension):
config.setdefault('rattail', 'app_package', 'rattail_demo')
# tell rattail where our stuff lives
config.setdefault('rattail', 'model', 'rattail_demo.db.model')
config.setdefault('rattail', 'model_spec', 'rattail_demo.db.model')
config.setdefault('rattail.trainwreck', 'model', 'rattail.trainwreck.db.model.defaults')
config.setdefault('tailbone.menus', 'handler', 'rattail_demo.web.menus:DemoMenuHandler')
config.setdefault('tailbone.static_libcache.module', 'rattail_demo.web.static')
# menus
config.setdefault('rattail.web.menus.handler_spec', 'rattail_demo.web.menus:DemoMenuHandler')
# default app handlers
config.setdefault('rattail', 'products.handler', 'rattail_corepos.products:CoreProductsHandler')

View file

@ -1,74 +0,0 @@
# -*- coding: utf-8; mode: python; -*-
"""
Alembic environment script
"""
from alembic import context
from sqlalchemy.orm import configure_mappers
from rattail.config import make_config
from rattail.db.util import get_default_engine
from rattail.db.continuum import configure_versioning
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
alembic_config = context.config
# use same config file for Rattail
rattail_config = make_config(alembic_config.config_file_name, usedb=False, versioning=False)
# configure Continuum..this is trickier than we want but it works..
configure_versioning(rattail_config, force=True)
from rattail_demo.db import model
configure_mappers()
# needed for 'autogenerate' support
target_metadata = model.Base.metadata
def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
engine = get_default_engine(rattail_config)
context.configure(
url=engine.url,
target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = get_default_engine(rattail_config)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()

View file

@ -7,7 +7,7 @@ from tailbone import menus as base
from tailbone_corepos.menus import make_corepos_menu
class DemoMenuHandler(base.MenuHandler):
class DemoMenuHandler(base.TailboneMenuHandler):
"""
Demo menu handler
"""
@ -62,7 +62,7 @@ class DemoMenuHandler(base.MenuHandler):
},
{
'title': "Source Code",
'url': 'https://kallithea.rattailproject.org/rattail-project/rattail-demo',
'url': 'https://forgejo.wuttaproject.org/rattail/rattail-demo',
'target': '_blank',
},
{

View file

@ -15,8 +15,8 @@ class UpgradeView(base.UpgradeView):
projects.update({
'rattail_demo': {
'commit_url': 'https://kallithea.rattailproject.org/rattail-project/rattail-demo/changelog/{new_version}/?size=10',
'release_url': 'https://kallithea.rattailproject.org/rattail-project/rattail-demo/files/{new_version}/CHANGES.rst',
'commit_url': 'https://forgejo.wuttaproject.org/rattail/rattail-demo/compare/{{old_version}}...{{new_version}}',
'release_url': 'https://forgejo.wuttaproject.org/rattail/rattail-demo/src/tag/v{{new_version}}/CHANGELOG.md',
},
})

View file

@ -3,50 +3,11 @@
Rattail Demo web API
"""
from __future__ import unicode_literals, absolute_import
from pyramid.config import Configurator
from pyramid.authentication import SessionAuthenticationPolicy
from tailbone import app
from tailbone.auth import TailboneAuthorizationPolicy
from tailbone import webapi as base
def main(global_config, **settings):
"""
This function returns a Pyramid WSGI application.
"""
# make config objects
rattail_config = app.make_rattail_config(settings)
pyramid_config = Configurator(settings=settings, root_factory=app.Root)
# configure user authorization / authentication
pyramid_config.set_authorization_policy(TailboneAuthorizationPolicy())
pyramid_config.set_authentication_policy(SessionAuthenticationPolicy())
# always require CSRF token protection
pyramid_config.set_default_csrf_options(require_csrf=True, token='_csrf', header='X-XSRF-TOKEN')
# bring in some Pyramid goodies
pyramid_config.include('tailbone.beaker')
pyramid_config.include('pyramid_tm')
pyramid_config.include('cornice')
# bring in the pyramid_retry logic, if available
# TODO: pretty soon we can require this package, hopefully..
try:
import pyramid_retry
except ImportError:
pass
else:
pyramid_config.include('pyramid_retry')
# add some permissions magic
pyramid_config.add_directive('add_tailbone_permission_group', 'tailbone.auth.add_permission_group')
pyramid_config.add_directive('add_tailbone_permission', 'tailbone.auth.add_permission')
# bring in some Tailbone
pyramid_config.include('tailbone.subscribers')
pyramid_config.include('tailbone.api')
return pyramid_config.make_wsgi_app()
return base.main(global_config, **settings)

23
tasks.py Normal file
View file

@ -0,0 +1,23 @@
# -*- coding: utf-8; -*-
"""
Tasks for rattail-demo
"""
import os
import shutil
from invoke import task
@task
def release(c):
"""
Release a new version of 'rattail-demo'
"""
if os.path.exists('dist'):
shutil.rmtree('dist')
if os.path.exists('rattail_demo.egg-info'):
shutil.rmtree('rattail_demo.egg-info')
c.run('python -m build --sdist')
c.run('twine upload dist/*')