fixed: compile issue
[opensg.git] / Bindings / Python / __init__.py.in
blob42c80b9f8bbff506a89ed270f83b3d30d321de55
1 # PyOpenSG is (C) Copyright 2005-2009 by Allen Bierbaum
3 # This file is part of PyOpenSG.
5 # PyOpenSG is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; either version 2 of the License, or (at your option)
8 # any later version.
10 # PyOpenSG is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
13 # more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # Init file for osg package.
22 # Hack to bring in all symbols OpenSG is linked against and loads from plugins
23 # Search for : setdlopenflags and RTLD_GLOBAL on google to see why
25 from ..OSGBase import AttachmentContainer
27 original_dlopen_flags = None
29 try:
30 import dl, sys
31 original_dlopen_flags = sys.getdlopenflags()
32 sys.setdlopenflags(original_dlopen_flags | dl.RTLD_GLOBAL)
33 except:
34 pass
36 # Import everything from the opensg module
37 from ${PROJECT_NAME}Py import *
39 if original_dlopen_flags:
40 sys.setdlopenflags(original_dlopen_flags)
42 def _fc_cmp(self, other):
43 """ Comparison operator for field containers. """
44 id_self = None
45 id_other = None
46 if not self is None:
47 id_self = self.getId()
48 if not other is None:
49 id_other = other.getId()
51 return cmp(id_self, id_other)
53 def _fc_hash(self):
54 if self is None:
55 return -1
56 else:
57 return self.getId()
59 for (n,c) in ${PROJECT_NAME}Py.__dict__.iteritems():
60 if isinstance(c,type) and (AttachmentContainer in c.__mro__):
61 c.__cmp__ = _fc_cmp
62 c.__hash__ = _fc_hash
64 # Add cored node types
65 import osg2.helpers.cored_node as cored_node
66 cored_node.addNodeCoreTypes(globals(), ${PROJECT_NAME}Py)