Package web2py :: Package gluon :: Module tools :: Class PluginManager

[hide private]
[frames] | no frames]

# Class PluginManager

source code

    object --+
             |
            PluginManager

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() >>> plugins.me.param1=3

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

### where the plugin is used >>> print plugins.me.param1 3 >>> print plugins.me.param2 6 >>> plugins.me.param3 = 8 >>> print plugins.me.param3 8

Here are some tests:

    >>> a=PluginManager()
    >>> a.x=6
    >>> b=PluginManager('check')
    >>> print b.x
    6
    >>> b=PluginManager() # reset settings
    >>> print b.x
    <Storage {}>
    >>> b.x=7
    >>> print a.x
    7
    >>> a.y.z=8
    >>> print b.y.z
    8
    >>> test_thread_separation()
    5
    >>> plugins=PluginManager('me',db='mydb')
    >>> print plugins.me.db
    mydb
    >>> print 'me' in plugins
    True
    >>> print plugins.me.installed
    True

Instance Methods | [hide private]

__init__(self, plugin=global_settings.applications_parent, **defaults) x.__init__(...) initializes x; see x.__class__.__doc__ for signature | source code

__getattr__(self, key) | source code

keys(self) | source code

__contains__(self, key) | source code

Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Static Methods | [hide private]

__new__(cls, *a, **b) Returns: a new object with type S, a subtype of T | 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=global_settings.applications_parent, **defaults)
(Constructor)

source code

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
  (inherited documentation)