13.2.1. Components and environment

NGW uses components for modularity. One python-пакет can contain one or several components. Each component inherits class Component, to load packages setuptools entry points are used.

def pkginfo():
    return dict(components=dict(

    name = 'somepackage',
    entry_points = {'nextgisweb.packages':
        'somepackage = somepackage:somemod:pkginfo'}

Each component has an ID (somecomp in an example above). The same ID is used in a class attribute identity. This ID must be unique among all packages of NGW.

To join components together instance of Env class is used, created at init. Initialization runs like this:

  1. Component instances are created

  2. initialize() is called for each component

  3. configure() is called for each component Dependencies between components

Method calls for initialize() and configure() happen in accordance with dependencies, which can be set using decorator require().

So, is you need to call initialize() of component B after A do this:

from nextgisweb.component import Component, require

class A(Component):
    identity = 'A'

    def initialize(self):

class B(Component):
    identity = 'B'

    def initialize(self):
        pass Global env object Component class Env class