Changeset - e3d8f4bc3ce7
[Not reviewed]
default
1 5 1
Thomas De Schampheleire - 5 years ago 2020-10-06 20:14:59
thomas.de_schampheleire@nokia.com
extensions: rename 'rcextensions' into 'extensions' but provide compatibility

The 'rc' prefix is legacy.
Rename 'rcextensions' into 'extensions', updating all references.
Compatibility with the old name will be retained for a while, and removed in
a later release. Migrating is as simple as renaming a file.
6 files changed with 29 insertions and 19 deletions:
0 comments (0 inline, 0 general)
docs/upgrade.rst
Show inline comments
 
@@ -39,8 +39,8 @@ Back up your configuration
 

	
 
Make a copy of your Kallithea configuration (``.ini``) file.
 

	
 
If you are using :ref:`rcextensions <customization>`, you should also
 
make a copy of the entire ``rcextensions`` directory.
 
If you are using custom :ref:`extensions <customization>`, you should also
 
make a copy of the ``extensions.py`` file.
 

	
 
Back up your database
 
^^^^^^^^^^^^^^^^^^^^^
docs/usage/customization.rst
Show inline comments
 
@@ -39,13 +39,14 @@ running::
 
.. _less: http://lesscss.org/
 

	
 

	
 
Behavioral customization: rcextensions
 
--------------------------------------
 
Behavioral customization: Kallithea extensions
 
----------------------------------------------
 

	
 
Some behavioral customization can be done in Python using ``rcextensions``, a
 
custom Python package that can extend Kallithea functionality.
 
Some behavioral customization can be done in Python using Kallithea
 
``extensions``, a custom Python file you can create to extend Kallithea
 
functionality.
 

	
 
With ``rcextensions`` it's possible to add additional mappings for Whoosh
 
With ``extensions`` it's possible to add additional mappings for Whoosh
 
indexing and statistics, to add additional code into the push/pull/create/delete
 
repository hooks (for example to send signals to build bots such as Jenkins) and
 
even to monkey-patch certain parts of the Kallithea source code (for example
 
@@ -55,9 +56,14 @@ To generate a skeleton extensions packag
 

	
 
    kallithea-cli extensions-create -c my.ini
 

	
 
This will create an ``rcextensions`` package next to the specified ``ini`` file.
 
See the ``__init__.py`` file inside the generated ``rcextensions`` package
 
for more details.
 
This will create an ``extensions.py`` file next to the specified ``ini`` file.
 
You can find more details inside this file.
 

	
 
For compatibility with previous releases of Kallithea, a directory named
 
``rcextensions`` with a file ``__init__.py`` inside of it can also be used. If
 
both an ``extensions.py`` file and an ``rcextensions`` directory are found, only
 
``extensions.py`` will be loaded. Note that the name ``rcextensions`` is
 
deprecated and support for it will be removed in a future release.
 

	
 

	
 
Behavioral customization: code changes
kallithea/bin/kallithea_cli_extensions.py
Show inline comments
 
@@ -33,15 +33,15 @@ from kallithea.lib.utils2 import ask_ok
 
def extensions_create():
 
    """Write template file for extending Kallithea in Python.
 

	
 
    An rcextensions directory with a __init__.py file will be created next to
 
    the ini file. Local customizations in that file will survive upgrades.
 
    The file contains instructions on how it can be customized.
 
    Create a template `extensions.py` file next to the ini file. Local
 
    customizations in that file will survive upgrades. The file contains
 
    instructions on how it can be customized.
 
    """
 
    here = kallithea.CONFIG['here']
 
    content = pkg_resources.resource_string(
 
        'kallithea', os.path.join('config', 'rcextensions', '__init__.py')
 
        'kallithea', os.path.join('config', 'extensions', 'extensions.py')
 
    )
 
    ext_file = os.path.join(here, 'rcextensions', '__init__.py')
 
    ext_file = os.path.join(here, 'extensions.py')
 
    if os.path.exists(ext_file):
 
        msg = ('Extension file %s already exists, do you want '
 
               'to overwrite it ? [y/n] ') % ext_file
kallithea/config/extensions/extensions.py
Show inline comments
 
file renamed from kallithea/config/rcextensions/__init__.py to kallithea/config/extensions/extensions.py
kallithea/lib/pygmentsutils.py
Show inline comments
 
@@ -69,7 +69,7 @@ def get_index_filenames():
 

	
 
def get_custom_lexer(extension):
 
    """
 
    returns a custom lexer if it's defined in rcextensions module, or None
 
    returns a custom lexer if it's defined in the extensions module, or None
 
    if there's no custom lexer defined
 
    """
 
    import kallithea
kallithea/lib/utils.py
Show inline comments
 
@@ -522,11 +522,15 @@ def repo2db_mapper(initial_repo_dict, re
 

	
 
def load_extensions(root_path):
 
    try:
 
        ext = create_module('rc', os.path.join(root_path, 'rcextensions', '__init__.py'))
 
        ext = create_module('extensions', os.path.join(root_path, 'extensions.py'))
 
    except FileNotFoundError:
 
        return
 
        try:
 
            ext = create_module('rc', os.path.join(root_path, 'rcextensions', '__init__.py'))
 
            log.warning('The name "rcextensions" is deprecated. Please use a file `extensions.py` instead of a directory `rcextensions`.')
 
        except FileNotFoundError:
 
            return
 

	
 
    log.info('Loaded rcextensions from %s', ext)
 
    log.info('Loaded Kallithea extensions from %s', ext)
 
    kallithea.EXTENSIONS = ext
 

	
 
    # Additional mappings that are not present in the pygments lexers
0 comments (0 inline, 0 general)