src/source/admln_guide/scripts.rst
branchdoc-dc
changeset 109 31b3d00edb8a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/source/admln_guide/scripts.rst	Tue Dec 11 16:29:56 2018 +0100
@@ -0,0 +1,49 @@
+.. _scripts:
+
+PyAMS maintenance scripts
+=========================
+
+
+pyams_upgrade
+-------------
+
+
+Pyramid allows to define custom command line scripts for application management. A script called *pyams_upgrade* is
+provided by PyAMS_utils package; this script apply the same process as PyAMS site factory, but can also be used to
+manage **database generations**. The idea behind this is just to allow custom packages to provide a way to check and
+upgrade database configuration away from application startup process:
+
+.. code-block:: bash
+
+    # ./bin/pyams_upgrade webapp/development.ini
+
+
+A **site generation checker** is just a named utility providing :py:class:`pyams_utils.interfaces.site.ISiteGenerations`
+interface. For example, **pyams_security** package provides such utility, to make sure that local site manager
+contains a PyAMS security manager and a principal annotation utility:
+
+.. code-block:: python
+
+    from pyams_utils.site import check_required_utilities
+
+    REQUIRED_UTILITIES = ((ISecurityManager, '', SecurityManager, 'Security manager'),
+                          (IPrincipalAnnotationUtility, '', PrincipalAnnotationUtility, 'User profiles'))
+
+    @utility_config(name='PyAMS security', provides=ISiteGenerations)
+    class SecurityGenerationsChecker(object):
+    """I18n generations checker"""
+
+        generation = 1
+
+        def evolve(self, site, current=None):
+            """Check for required utilities"""
+            check_required_utilities(site, REQUIRED_UTILITIES)
+
+:py:func:`check_required_utilities <pyams_utils.site.check_required_utilities>` is a PyAMS_utils utility function which
+can to used to verify that a set of local utilities are correctly registered with the given names and interfaces.
+
+
+zodbupdate
+----------
+
+:ref:`renamehowto`