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