src/source/dev_guide/adv-features.rst
branchdoc-dc
changeset 122 7e69ecc9fd43
parent 114 8032f81fba95
child 126 e0584f3de3fd
equal deleted inserted replaced
121:98a84761634f 122:7e69ecc9fd43
     9 ---------------------------
     9 ---------------------------
    10 
    10 
    11 Renaming persistent classes
    11 Renaming persistent classes
    12 ---------------------------
    12 ---------------------------
    13 
    13 
       
    14 PyAMS provides `zodbupdate` script to update easily update the change in ZODB. Because, when you develop new features
       
    15 to PyAMS we sometimes have to rename or modify classes of already stored objects and if you do that you will never access
       
    16 yours objects.
       
    17 
       
    18 To rename classes of existing objects:
       
    19 
       
    20 **1) Include you package in the require resource for you webapp**
       
    21 
       
    22 
       
    23 .. code-block:: python
       
    24 
       
    25     requires = [
       
    26         'mypackage',
       
    27         ...
       
    28     ]
       
    29 
       
    30 **2) Add the Entry points**
       
    31 
       
    32 
       
    33 In the `setup.py` file add 'zodbupdate' params into entry_points where is store zodbupdate directives
       
    34 
       
    35 .. code-block:: python
       
    36 
       
    37       entry_points={
       
    38           'zodbupdate': [
       
    39               'renames = mypackage.generations:RENAMED_CLASSES'
       
    40           ]
       
    41       }
       
    42 
       
    43 
       
    44 
       
    45 **3) Create a module named** ``generation`` **with the migration directives**
       
    46 
       
    47 
       
    48 .. code-block:: python
       
    49 
       
    50     RENAMED_CLASSES = {
       
    51         'mypackage.mymodule MyOldClass': 'mypackage.mymodule MyNewClass'
       
    52     }
       
    53 
       
    54 
       
    55 **4) Run the commands** ``buildout`` .
       
    56 
       
    57 .. code-block:: console
       
    58 
       
    59     $ mypackage/bin/buildout
       
    60     $ webapp/bin/buildout
       
    61 
       
    62 
       
    63 The ``buildout`` command going to install correctly the package and add the new entry_points references in entry_points.txt
       
    64 
       
    65 **5)  Run the commands** ``zodbupdate``
       
    66 
       
    67 To finish run `zodbupdate` to apply the changes describe in `RENAMED_CLASSES`
       
    68 
       
    69 .. code-block:: console
       
    70 
       
    71     $   bin/zodbupdate --config etc/zodbupdate-zeo.conf
       
    72 
       
    73 
       
    74 Where `zodbupdate-zeo.conf` is the configuration file to access to the ZODB.
       
    75 
    14 Including SQLAlchemy
    76 Including SQLAlchemy
    15 --------------------
    77 --------------------
    16 
    78 
    17 Using GIS features
    79 Using GIS features
    18 ------------------
    80 ------------------