diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c95667..76568fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,6 @@ All notable changes to wuttaweb 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.10.1 (2024-08-19) - -### Fix - -- make `util.get_model_fields()` work with more model classes - ## v0.10.0 (2024-08-18) ### Feat diff --git a/pyproject.toml b/pyproject.toml index cc4cdf2..bfaf855 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "WuttaWeb" -version = "0.10.1" +version = "0.10.0" description = "Web App for Wutta Framework" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@edbob.org"}] diff --git a/src/wuttaweb/auth.py b/src/wuttaweb/auth.py index e152576..88b1fea 100644 --- a/src/wuttaweb/auth.py +++ b/src/wuttaweb/auth.py @@ -150,7 +150,7 @@ class WuttaSecurityPolicy: return auth.has_permission(self.db_session, user, permission) -def add_permission_group(pyramid_config, groupkey, label=None, overwrite=True): +def add_permission_group(pyramid_config, key, label=None, overwrite=True): """ Pyramid directive to add a "permission group" to the app's awareness. @@ -169,12 +169,12 @@ def add_permission_group(pyramid_config, groupkey, label=None, overwrite=True): pyramid_config.add_permission_group('widgets', label="Widgets") - :param groupkey: Unique key for the permission group. In the - context of a master view, this will be the same as + :param key: Unique key for the permission group. In the context + of a master view, this will be the same as :attr:`~wuttaweb.views.master.MasterView.permission_prefix`. :param label: Optional label for the permission group. If not - specified, it is derived from ``groupkey``. + specified, it is derived from ``key``. :param overwrite: If the permission group was already established, this flag controls whether the group's label should be @@ -186,9 +186,9 @@ def add_permission_group(pyramid_config, groupkey, label=None, overwrite=True): app = config.get_app() def action(): perms = pyramid_config.get_settings().get('wutta_permissions', {}) - if overwrite or groupkey not in perms: - group = perms.setdefault(groupkey, {'key': groupkey}) - group['label'] = label or app.make_title(groupkey) + if overwrite or key not in perms: + group = perms.setdefault(key, {'key': key}) + group['label'] = label or app.make_title(key) pyramid_config.add_settings({'wutta_permissions': perms}) pyramid_config.action(None, action) @@ -215,8 +215,8 @@ def add_permission(pyramid_config, groupkey, key, label=None): pyramid_config.add_permission('widgets', 'widgets.polish', label="Polish all the widgets") - :param groupkey: Unique key for the permission group. In the - context of a master view, this will be the same as + :param key: Unique key for the permission group. In the context + of a master view, this will be the same as :attr:`~wuttaweb.views.master.MasterView.permission_prefix`. :param key: Unique key for the permission. This should be the diff --git a/src/wuttaweb/forms/base.py b/src/wuttaweb/forms/base.py index 6b16bdd..59cdc04 100644 --- a/src/wuttaweb/forms/base.py +++ b/src/wuttaweb/forms/base.py @@ -182,8 +182,6 @@ class Form: String name for Vue component tag. By default this is ``'wutta-form'``. See also :meth:`render_vue_tag()`. - See also :attr:`vue_component`. - .. attribute:: align_buttons_right Flag indicating whether the buttons (submit, cancel etc.) @@ -786,13 +784,6 @@ class Form: - - .. todo:: Why can't Sphinx render the above code block as 'html' ? diff --git a/src/wuttaweb/grids/base.py b/src/wuttaweb/grids/base.py index 9a6b195..e193109 100644 --- a/src/wuttaweb/grids/base.py +++ b/src/wuttaweb/grids/base.py @@ -86,9 +86,9 @@ class Grid: .. attribute:: columns - :class:`~wuttaweb.util.FieldList` instance containing string - column names for the grid. Columns will appear in the same - order as they are in this list. + :class:`~wuttaweb.forms.base.FieldList` instance containing + string column names for the grid. Columns will appear in the + same order as they are in this list. See also :meth:`set_columns()` and :meth:`get_columns()`. @@ -239,9 +239,9 @@ class Grid: .. attribute:: paginated - Boolean indicating whether the grid data should be paginated, - i.e. split up into pages. Default is ``False`` which means all - data is shown at once. + Boolean indicating whether the grid data should be paginated + vs. all data shown at once. Default is ``False`` which means + the full set of grid data is sent for each request. See also :attr:`pagesize` and :attr:`page`, and :attr:`paginate_on_backend`. @@ -392,7 +392,7 @@ class Grid: Explicitly set the list of grid columns. This will overwrite :attr:`columns` with a new - :class:`~wuttaweb.util.FieldList` instance. + :class:`~wuttaweb.forms.base.FieldList` instance. :param columns: List of string column names. """ @@ -440,8 +440,9 @@ class Grid: :param label: New label for the column header. - See also :meth:`get_label()`. Label overrides are tracked via - :attr:`labels`. + See also :meth:`get_label()`. + + Label overrides are tracked via :attr:`labels`. """ self.labels[key] = label @@ -489,7 +490,7 @@ class Grid: def render_foo(record, key, value): return HTML.literal("
this is the final cell value
") - grid = Grid(request, columns=['foo', 'bar']) + grid = Grid(columns=['foo', 'bar']) grid.set_renderer('foo', render_foo) Renderer overrides are tracked via :attr:`renderers`. @@ -508,8 +509,8 @@ class Grid: URL for this will be the same as for the "View" :class:`GridAction` (aka. :meth:`~wuttaweb.views.master.MasterView.view()`). - Although of course each cell in the column gets a different - link depending on which data record it points to. + Although of course each cell gets a different link depending + on which data record it points to. It is typical to enable auto-link for fields relating to ID, description etc. or some may prefer to auto-link all columns. @@ -608,8 +609,8 @@ class Grid: The term "model property" is a bit technical, an example should help to clarify:: - model = app.model - grid = Grid(request, model_class=model.Person) + model = self.app.model + grid = Grid(self.request, model_class=model.Person) # explicit property sorter = grid.make_sorter(model.Person.full_name) @@ -632,7 +633,7 @@ class Grid: ] # nb. no model_class, just as an example - grid = Grid(request, columns=['foo', 'bar'], data=data) + grid = Grid(self.request, columns=['foo', 'bar'], data=data) def getkey(obj): if obj.get('foo') @@ -724,8 +725,8 @@ class Grid: A backend sorter callable must accept ``(data, direction)`` args and return the sorted data/query, for example:: - model = app.model - grid = Grid(request, model_class=model.Person) + model = self.app.model + grid = Grid(self.request, model_class=model.Person) def sort_full_name(query, direction): sortspec = getattr(model.Person.full_name, direction) @@ -749,10 +750,6 @@ class Grid: """ Remove the backend sorter for a column. - Note that this removes the sorter *function*, so there is - no way to sort by this column unless another sorter is - later defined for it. - See also :meth:`set_sorter()`. """ self.sorters.pop(key, None) @@ -1143,7 +1140,6 @@ class Grid: See also these methods which may be called by this one: - * :meth:`sort_data()` * :meth:`paginate_data()` """ data = self.data or [] @@ -1287,7 +1283,6 @@ class Grid: { 'field': 'foo', 'label': "Foo", - 'sortable': True, } See also :meth:`get_vue_data()`. diff --git a/src/wuttaweb/util.py b/src/wuttaweb/util.py index 0b230b4..2f0e592 100644 --- a/src/wuttaweb/util.py +++ b/src/wuttaweb/util.py @@ -462,13 +462,14 @@ def get_model_fields(config, model_class=None): if not model_class: return - try: - mapper = sa.inspect(model_class) - except sa.exc.NoInspectionAvailable: - pass - else: - fields = [prop.key for prop in mapper.iterate_properties] - return fields + app = config.get_app() + model = app.model + if not issubclass(model_class, model.Base): + return + + mapper = sa.inspect(model_class) + fields = [prop.key for prop in mapper.iterate_properties] + return fields def make_json_safe(value, key=None, warn=True): diff --git a/src/wuttaweb/views/master.py b/src/wuttaweb/views/master.py index d43de9e..cc5af63 100644 --- a/src/wuttaweb/views/master.py +++ b/src/wuttaweb/views/master.py @@ -259,7 +259,7 @@ class MasterView(View): .. attribute:: form_fields - List of fields for the model form. + List of columns for the model form. This is optional; see also :meth:`get_form_fields()`. diff --git a/src/wuttaweb/views/people.py b/src/wuttaweb/views/people.py index 5097d06..e216027 100644 --- a/src/wuttaweb/views/people.py +++ b/src/wuttaweb/views/people.py @@ -101,7 +101,6 @@ class PersonView(MasterView): @classmethod def defaults(cls, config): - """ """ cls._defaults(config) cls._people_defaults(config) diff --git a/src/wuttaweb/views/roles.py b/src/wuttaweb/views/roles.py index 0da0712..3f2e350 100644 --- a/src/wuttaweb/views/roles.py +++ b/src/wuttaweb/views/roles.py @@ -246,7 +246,6 @@ class RoleView(MasterView): @classmethod def defaults(cls, config): - """ """ cls._defaults(config) cls._role_defaults(config)