close Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Initial Version and Version 1 of ApplicationObject


Ignore:
Timestamp:
Jun 25, 2008, 3:25:02 PM (16 years ago)
Author:
cmlenz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ApplicationObject

    v1 v1  
     1= Application Object =
     2
     3There can only be one instance of a `diva.core.Application` per Python interpreter. That is because the application is in many places accessed via the `app` singleton, which provides thread-local access to the application context.
     4
     5Usually a specific application will define a subclass of `diva.core.Application` that is explicitly instantiated at startup:
     6
     7{{{
     8#!pycon
     9>>> from diva.core import Application
     10>>>
     11>>> class MyApp(Application):
     12...    pass
     13...
     14>>> myapp = MyApp()
     15}}}
     16
     17After this point, you'll be able to access the singleton instance of the application using a simple import:
     18
     19{{{
     20#!pycon
     21>>> from diva import app
     22>>> app
     23<diva.ApplicationProxy object at …>
     24}}}
     25
     26This application proxy forwards all operations to the actual application class. The application class has a `ctxt` property that provides access to various thread-local objects, such as the current HTTP request.