2008-05-28 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / pyatspi / __init__.py
1 '''
2 Wraps the Gnome Assistive Technology Service Provider Interface for use in
3 Python. Imports the bonobo and ORBit modules. Initializes the ORBit ORB.
4 Activates the bonobo Accessibility Registry. Loads the Accessibility typelib
5 and imports the classes implementing the AT-SPI interfaces.
6
7 @var Registry: Reference to the AT-SPI registry daemon intialized on successful
8   import
9 @type Registry: registry.Registry
10
11 @author: Peter Parente
12 @organization: IBM Corporation
13 @copyright: Copyright (c) 2005, 2007 IBM Corporation
14 @license: LGPL
15
16 This library is free software; you can redistribute it and/or
17 modify it under the terms of the GNU Library General Public
18 License as published by the Free Software Foundation; either
19 version 2 of the License, or (at your option) any later version.
20
21 This library is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24 Library General Public License for more details.
25
26 You should have received a copy of the GNU Library General Public
27 License along with this library; if not, write to the
28 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA.
30
31 Portions of this code originally licensed and copyright (c) 2005, 2007
32 IBM Corporation under the BSD license, available at
33 U{http://www.opensource.org/licenses/bsd-license.php}
34 '''
35
36 REGISTRY_IID = "OAFIID:Accessibility_Registry:1.0"
37 TYPELIB_NAME = "Accessibility"
38
39 # import ORBit and bonobo first (required)
40 import ORBit, bonobo
41 # initialize the ORB
42 orb = ORBit.CORBA.ORB_init()
43 # get a reference to the gnome Accessibility registry
44 reg = bonobo.activation.activate_from_id(REGISTRY_IID, 0, 0)
45 if reg is None:
46   raise RuntimeError('could not activate:', REGISTRY_IID)
47 # generate Python code for the Accessibility module from the IDL
48 ORBit.load_typelib(TYPELIB_NAME)
49
50 # import our registry module
51 import registry
52 # wrap the raw registry object in our convenience singleton
53 Registry = registry.Registry(reg)
54 # overwrite the registry class in the module, so all other imports get our
55 # singleton
56 registry.Registry = Registry
57 # now throw the module away immediately
58 del registry
59
60 # pull the cache level functions into this namespace, but nothing else
61 from accessible import setCacheLevel, getCacheLevel, clearCache, printCache
62
63 # pull constants and utilities directly into this namespace; rest of code
64 # never has to be touched externally
65 from constants import *
66 from utils import *
67
68 # throw away extra references
69 del reg
70 del orb