annotate docs/api/models.rst @ 8163:24e1099e4f29

py3: make get_current_authuser handle missing tg context consistently and explicitly tg context handling ends up using tg.support.registry.StackedObjectProxy._current_obj for attribute access ... which if no context has been pushed will end up in: raise TypeError( 'No object (name: %s) has been registered for this ' 'thread' % self.____name__) utils2.get_current_authuser used code like: if hasattr(tg.tmpl_context, 'authuser'): Python 2 hasattr will call __getattr__ and return False if it throws any exception. (It would thus catch the TypeError and silently fall through to use the default user None.) This hasattr behavior is confusing and hard to use correctly. Here, it was used incorrectly. It has been common practice to work around by using something like: getattr(x, y, None) is not None Python 3 hasattr fixed this flaw and only catches AttributeError. The TypeError would thus (rightfully) be propagated. That is a change that must be handled when introducing py3 support. The get_current_authuser code could more clearly and simple and py3-compatible be written as: return getattr(tmpl_context, 'authuser', None) - but then we also have to handle the TypeError explicitly ... which we are happy to do.
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 31 Jan 2020 18:48:15 +0100
parents cd6c577ade97
children b6b6955981a5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
849
64a5386216c5 Fixed models link at documentation
Lukasz Balcerzak <lukasz.balcerzak@python-center.org>
parents: 811
diff changeset
1 .. _models:
811
bb35ad076e2f docs updates
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2
2095
Marcin Kuzminski <marcin@python-works.com>
parents: 1839
diff changeset
3 ========================
5413
22a3fa3c4254 docs: cleanup of casing, markup and spacing of headings
Mads Kiilerich <madski@unity3d.com>
parents: 4226
diff changeset
4 The :mod:`models` module
811
bb35ad076e2f docs updates
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5 ========================
bb35ad076e2f docs updates
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3224
diff changeset
7 .. automodule:: kallithea.model
811
bb35ad076e2f docs updates
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 :members:
3224
8b8edfc25856 whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2095
diff changeset
9
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3224
diff changeset
10 .. automodule:: kallithea.model.comment
1839
9da24750f563 docs update
Marcin Kuzminski <marcin@python-works.com>
parents: 849
diff changeset
11 :members:
3224
8b8edfc25856 whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2095
diff changeset
12
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3224
diff changeset
13 .. automodule:: kallithea.model.permission
811
bb35ad076e2f docs updates
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 :members:
1839
9da24750f563 docs update
Marcin Kuzminski <marcin@python-works.com>
parents: 849
diff changeset
15
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3224
diff changeset
16 .. automodule:: kallithea.model.repo_permission
3224
8b8edfc25856 whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2095
diff changeset
17 :members:
1839
9da24750f563 docs update
Marcin Kuzminski <marcin@python-works.com>
parents: 849
diff changeset
18
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3224
diff changeset
19 .. automodule:: kallithea.model.repo
3224
8b8edfc25856 whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2095
diff changeset
20 :members:
811
bb35ad076e2f docs updates
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21
4226
499c513967a1 docs: fix building html
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4186
diff changeset
22 .. automodule:: kallithea.model.repo_group
1839
9da24750f563 docs update
Marcin Kuzminski <marcin@python-works.com>
parents: 849
diff changeset
23 :members:
3224
8b8edfc25856 whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2095
diff changeset
24
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3224
diff changeset
25 .. automodule:: kallithea.model.scm
811
bb35ad076e2f docs updates
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 :members:
3224
8b8edfc25856 whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2095
diff changeset
27
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3224
diff changeset
28 .. automodule:: kallithea.model.user
3224
8b8edfc25856 whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2095
diff changeset
29 :members:
8b8edfc25856 whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2095
diff changeset
30
4226
499c513967a1 docs: fix building html
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4186
diff changeset
31 .. automodule:: kallithea.model.user_group
3224
8b8edfc25856 whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2095
diff changeset
32 :members: