1.1.1. Export Manager

The export manager module allows to export a list of social nodes to others formats getting the results in different ways. So, the export manager is composed by two main phases:
  • The social nodes are changed to other format. For example: from social nodes to json
  • The information with this new format is returned with a selected mechanism. For example an http response.

With this export manager is very easy to return and export information managed by LibreGeoSocial (social nodes) to other possible formats used by any application. In fact, any query done it in the core of LibreGeoSocial returns a list of Social Nodes, if we are using the REST interface, these social nodes are going to pass through the export manager to format it to json with an HTTPResponse. Alike, the export manager could be used to export a complete layer using xml format and storing it to a file, in order to make a backup.

1.1.1.1. How it works

Following a description of the module, with his main class and methods:

class Export_Manager

This is the class to instance, in order to use the export manager.

configure(exportEngine, outputEninge, backup, viewer)

After instance the class, you have to configure the different engines of the export manager:

Parameters:
  • exportEngine (string) – supported engines: “json”, “xml”
  • outputEngine (string) – supported engines: “HTTPResponse”
  • backup (boolean) – the export result of the data include binaries
  • viewer – the user making the export process. None for no privacy
export(socialNodes, extraInfo[, viewer])

This method will export the list of social nodes regarding the configured engines.

Parameters:
  • socialNodes (Social_node) – a list of social nodes objects
  • extraInfo (dictionary) – a dict with extra info that could be used by the format engine to add extra information.
  • viewer – LibreGeoSocial user requesting the export proccess
Return type:

the result will depend on the ouputEngine, containing the social nodes information in the new format.

Next an example of how to use the export manager. This example is quite similar to the process used by the layers system returning information by the REST interface:

from social.export_manager.export_manager import Export_Manager
from social.core.api_photo import get_all

node_list = get_all()

exportManager = Export_Manager()
exportManager.configure("json", "HTTPResponse", backup = "False", "anonymous")
exportManager.export(node_list, None, None)

1.1.1.2. Class Diagram

Next a class diagram of the functional module.

../../../_images/Classdiagram.png

Table Of Contents

Previous topic

1. Functional API

Next topic

2. Rest API

This Page

  • Show Source