5.2.8 draco.application -- the Application object

The Application class is a global Draco object that provides functionality for application variables and locking. Application variables are variables that are shared among all handlers and templates in the web application. They persist until the web server stops or restarts. The global instance of the Application class is stored under the name application in the current module.

Application variables depend on database access and are not available when there is no database access. You can check if application variables are available by testing the application instance for non-zeroness.

The Application object is a namespace. Use Python's dictionary notation to get, set or remove application variables from the Application object. A small example:

from draco.application import application

application['ham'] = 'spam'
del application['ham']

class Application( )
Global Draco object that implements application variables and locking.

The public methods of Application are:

namespace( scope)
Return an application subnamespace with scope scope. Application namespaces with different scopes are independant. The default namespace (the one available from the global Application object) has the scope '__system__'.

lock( )
Lock the application. If the application is already locked, this waits until the lock is released and a new lock can be obtained. Application locking should be used with care because it introduces serialization points in your application that can easily degrade performance.

unlock( )
Unlock the application.