Exchanging data

Planop can exchange data with other planop installations, by dumping and loading information into a json data file.

Loading

To load information from a json file:

python manage.py planopload path/to/xx.json

The information of the json file gets loaded into the database. It will not override existing data. Mind that depending on the information in the json file, items may be linked to existing items.

Dumping

You can dump the entire planop database into a json file with the command:

python manage.py dumpdata > xx.json

If you need to dump only part of the planop information, you will need to write a small script selecting exactly the data you want to dump. All objects have a dump method, you can use to print out the info.

An example script to dump a deviations suggestion list:

import sys
sys.path.append('path/to/planop/')

from django.core.management import setup_environ

import settings
setup_environ(settings)

from analyses.deviations.models import DeviationSuggestionlist
from utils.versioning.models import WorkVersion

def main():
    sl = DeviationSuggestionlist.objects.get_versionedobject(v_id=1, version=WorkVersion)
    print sl.dump()

if __name__ == "__main__":
    main()