1 .. _scripts: |
1 .. _scripts: |
2 |
2 |
3 PyAMS maintenance scripts |
3 PyAMS maintenance scripts |
4 ========================= |
4 ========================= |
5 |
5 |
|
6 |
|
7 pyams_upgrade |
|
8 ------------- |
|
9 |
|
10 |
|
11 Pyramid allows to define custom command line scripts for application management. A script called *pyams_upgrade* is |
|
12 provided by PyAMS_utils package; this script apply the same process as PyAMS site factory, but can also be used to |
|
13 manage **database generations**. The idea behind this is just to allow custom packages to provide a way to check and |
|
14 upgrade database configuration away from application startup process: |
|
15 |
|
16 .. code-block:: bash |
|
17 |
|
18 # ./bin/pyams_upgrade webapp/development.ini |
|
19 |
|
20 |
|
21 A **site generation checker** is just a named utility providing :py:class:`pyams_utils.interfaces.site.ISiteGenerations` |
|
22 interface. For example, **pyams_security** package provides such utility, to make sure that local site manager |
|
23 contains a PyAMS security manager and a principal annotation utility: |
|
24 |
|
25 .. code-block:: python |
|
26 |
|
27 from pyams_utils.site import check_required_utilities |
|
28 |
|
29 REQUIRED_UTILITIES = ((ISecurityManager, '', SecurityManager, 'Security manager'), |
|
30 (IPrincipalAnnotationUtility, '', PrincipalAnnotationUtility, 'User profiles')) |
|
31 |
|
32 @utility_config(name='PyAMS security', provides=ISiteGenerations) |
|
33 class SecurityGenerationsChecker(object): |
|
34 """I18n generations checker""" |
|
35 |
|
36 generation = 1 |
|
37 |
|
38 def evolve(self, site, current=None): |
|
39 """Check for required utilities""" |
|
40 check_required_utilities(site, REQUIRED_UTILITIES) |
|
41 |
|
42 :py:func:`check_required_utilities <pyams_utils.site.check_required_utilities>` is a PyAMS_utils utility function which |
|
43 can to used to verify that a set of local utilities are correctly registered with the given names and interfaces. |
|
44 |