The provider class is the root class of the module. It keeps the common information needed by all services provided by this “provider”.
Think about a provider as the class that will declare all stuff neded by core and child services to provide and administrator user a way to create services to be consumed by users.
One good example is a Virtualization server. Here we keep information about that server (ip address, protocol, ....) and services provided by that “provider” will make use of that information to make the administrator not provide it once an again for every service we put on that virtualization server.
For a detailed example of a service provider, you can see the provided provider sample
Base Service Provider Class.
All classes that will represent a service provider will need to be derived from this class.
The preferred way of using this class is by its alias name, provided at uds.core.services module, ServiceProvider.
This is a very basic class, intended to be the root class of services. This means that services are childs of this class, declared at “offers” attribute.
As you derive from this class, if you provide __init__ in your own class, remember to call ALWAYS at base class __init__ as this:
super(...., self).__init__(environment, values)
The preferred method of provide initialization is to provide the initialize(), and do not overrie __init__ method. This (initialize) will be invoked after all internal initialization.
This is a MUST, so internal structured gets filled correctly, so don’t forget it!.
Normally objects of classes deriving from this one, will be serialized, called, deserialized. This means that all that you want to ensure that is keeped inside the class must be serialized and unserialized, because there is no warantee that the object will get two methods invoked without haven’t been removed from memory and loaded again. One thing to have into account on this are Form Fields, that default implementation marshals and unmashals them, so if your case is that you only need data that is keeped at form fields, marshal and unmarshal and in fact not needed.
Tries to locate a child service which type corresponds with the one provided. Returns None if can’t find one.
Note: | The type that this method looks for is not the class, but the typeType that Service has. |
---|
Returns what type of services this provider offers
This method will be invoked from __init__ constructor. This is provided so you don’t have to provide your own __init__ method, and invoke base methods. This will get invoked when all initialization stuff is done
Default implementation does nothing