view docs/index.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 99edd97366e3
children 89e9aef9b983
line wrap: on
line source

.. _index:

#######################
Kallithea Documentation
#######################

* :ref:`genindex`
* :ref:`search`


Readme
******

.. toctree::
   :maxdepth: 1

   readme


Administrator guide
*******************

**Installation and upgrade**

.. toctree::
   :maxdepth: 1

   overview
   installation
   installation_win
   installation_win_old
   installation_iis
   installation_puppet
   upgrade

**Setup and configuration**

.. toctree::
   :maxdepth: 1

   setup
   administrator_guide/auth
   administrator_guide/vcs_setup
   usage/email
   usage/customization

**Maintenance**

.. toctree::
   :maxdepth: 1

   usage/backup
   usage/performance
   usage/debugging
   usage/troubleshooting


User guide
**********

.. toctree::
   :maxdepth: 1

   usage/general
   usage/vcs_notes
   usage/statistics
   api/api


Developer guide
***************

.. toctree::
   :maxdepth: 1

   contributing
   dev/translation
   dev/dbmigrations


.. _virtualenv: http://pypi.python.org/pypi/virtualenv
.. _python: http://www.python.org/
.. _django: http://www.djangoproject.com/
.. _mercurial: https://www.mercurial-scm.org/
.. _bitbucket: http://bitbucket.org/
.. _subversion: http://subversion.tigris.org/
.. _git: http://git-scm.com/
.. _celery: http://celeryproject.org/
.. _Sphinx: http://sphinx.pocoo.org/
.. _vcs: http://pypi.python.org/pypi/vcs