Package gluon :: Module tools :: Class PluginManager
[hide private]
[frames] | no frames]

Class PluginManager

source code

object --+

Plugin Manager is similar to a storage object but it is a single level singleton this means that multiple instances within the same thread share the same attributes Its constructor is also special. The first argument is the name of the plugin you are defining. The named arguments are parameters needed by the plugin with default values. If the parameters were previous defined, the old values are used.

For example:

### in some general configuration file: >>> plugins = PluginManager() >>>

### within the plugin model >>> _ = PluginManager('me',param1=5,param2=6,param3=7)

### where the plugin is used >>> print 3 >>> print 6 >>> = 8 >>> print 8

Here are some tests:

>>> a=PluginManager()
>>> a.x=6
>>> b=PluginManager('check')
>>> print b.x
>>> b=PluginManager() # reset settings
>>> print b.x
<Storage {}>
>>> b.x=7
>>> print a.x
>>> a.y.z=8
>>> print b.y.z
>>> test_thread_separation()
>>> plugins=PluginManager('me',db='mydb')
>>> print
>>> print 'me' in plugins
>>> print
Instance Methods [hide private]
__init__(self, plugin=None, **defaults)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
__getattr__(self, key) source code
keys(self) source code
__contains__(self, key) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
a new object with type S, a subtype of T
__new__(cls, *a, **b) source code
Class Variables [hide private]
  instances = {}
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__new__(cls, *a, **b)
Static Method

source code 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__
(inherited documentation)

__init__(self, plugin=None, **defaults)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)