source: trunk/third/libxslt/python/libxsl.py @ 18543

Revision 18543, 2.5 KB checked in by ghudson, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18542, which included commits to RCS files with non-trunk default branches.
Line 
1#
2# Both libxml2mod and libxsltmod have a dependancy on libxml2.so
3# and they should share the same module, try to convince the python
4# loader to work in that mode if feasible
5#
6import sys
7if not hasattr(sys,'getdlopenflags'):
8    import libxml2mod
9    import libxsltmod
10    import libxml2
11else:
12    try:
13        from dl import RTLD_GLOBAL, RTLD_NOW
14    except ImportError:
15        RTLD_GLOBAL = -1
16        RTLD_NOW = -1
17        try:
18            import os
19            osname = os.uname()[0]
20            if osname == 'Linux':
21                RTLD_GLOBAL = 0x00100
22                RTLD_NOW = 0x00002
23            #
24            # is there a better method ?
25            #
26            else:
27                print "libxslt could not guess RTLD_GLOBAL and RTLD_NOW " + \
28                      "on this platform: %s" % (osname)
29        except:
30            print "libxslt could not guess RTLD_GLOBAL and RTLD_NOW " + \
31                  "on this platform: %s" % (osname)
32
33    if RTLD_GLOBAL != -1 and RTLD_NOW != -1:
34        try:
35            flags = sys.getdlopenflags()
36            sys.setdlopenflags(RTLD_GLOBAL | RTLD_NOW)
37            try:
38                import libxml2mod
39                import libxsltmod
40                import libxml2
41            finally:
42                sys.setdlopenflags(flags)
43        except:
44            import libxml2mod
45            import libxsltmod
46            import libxml2
47    else:
48        import libxml2mod
49        import libxsltmod
50        import libxml2
51
52class extensionModule:
53    def _styleInit(self, style, URI):
54        return self.styleInit(stylesheet(_obj=style), URI)
55
56    def _styleShutdown(self, style, URI, data):
57        return self.styleShutdown(stylesheet(_obj=style), URI, data)
58
59    def _ctxtInit(self, ctxt, URI):
60        return self.ctxtInit(transformCtxt(_obj=ctxt), URI)
61
62    def _ctxtShutdown(self, ctxt, URI, data):
63        return self.ctxtShutdown(transformCtxt(_obj=ctxt), URI, data)
64
65    def styleInit(self, style, URI):
66        """Callback function when used in a newly compiled stylesheet,
67           the return value is passed in subsequent calls"""
68        pass
69
70    def styleShutdown(self, style, URI, data):
71        """Callback function when a stylesheet using it is destroyed"""
72        pass
73
74    def ctxtInit(self, ctxt, URI):
75        """Callback function when used in a new transformation process,
76           the return value is passed in subsequent calls"""
77        pass
78
79    def ctxtShutdown(self, ctxt, URI, data):
80        """Callback function when a transformation using it finishes"""
81        pass
82
83#
84# Everything below this point is automatically generated
85#
86
Note: See TracBrowser for help on using the repository browser.