1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-04-23 14:45:32 +03:00
libxslt/python/libxsl.py
Daniel Veillard d932aafe73 fixing bug #101602 for extension modules init and shutdown callbacks,
* libxslt/extensions.c libxslt/transform.c: fixing bug #101602
  for extension modules init and shutdown callbacks, check that
  they are now called when needed.
* python/libxsl.py python/libxslt-python-api.xml python/libxslt.c:
  started adding the extension module support at the Python level.
  Still a strange bug to hunt down left.
Daniel
2003-01-13 22:28:34 +00:00

87 lines
2.5 KiB
Python

#
# Both libxml2mod and libxsltmod have a dependancy on libxml2.so
# and they should share the same module, try to convince the python
# loader to work in that mode if feasible
#
import sys
if not hasattr(sys,'getdlopenflags'):
import libxml2mod
import libxsltmod
import libxml2
else:
try:
from dl import RTLD_GLOBAL, RTLD_NOW
except ImportError:
RTLD_GLOBAL = -1
RTLD_NOW = -1
try:
import os
osname = os.uname()[0]
if osname == 'Linux':
RTLD_GLOBAL = 0x00100
RTLD_NOW = 0x00002
#
# is there a better method ?
#
else:
print "libxslt could not guess RTLD_GLOBAL and RTLD_NOW " + \
"on this platform: %s" % (osname)
except:
print "libxslt could not guess RTLD_GLOBAL and RTLD_NOW " + \
"on this platform: %s" % (osname)
if RTLD_GLOBAL != -1 and RTLD_NOW != -1:
try:
flags = sys.getdlopenflags()
sys.setdlopenflags(RTLD_GLOBAL | RTLD_NOW)
try:
import libxml2mod
import libxsltmod
import libxml2
finally:
sys.setdlopenflags(flags)
except:
import libxml2mod
import libxsltmod
import libxml2
else:
import libxml2mod
import libxsltmod
import libxml2
class extensionModule:
def _styleInit(self, style, URI):
return self.styleInit(stylesheet(_obj=style), URI)
def _styleShutdown(self, style, URI, data):
return self.styleShutdown(stylesheet(_obj=style), URI, data)
def _ctxtInit(self, ctxt, URI):
return self.ctxtInit(transformCtxt(_obj=ctxt), URI)
def _ctxtShutdown(self, ctxt, URI, data):
return self.ctxtShutdown(transformCtxt(_obj=ctxt), URI, data)
def styleInit(self, style, URI):
"""Callback function when used in a newly compiled stylesheet,
the return value is passed in subsequent calls"""
pass
def styleShutdown(self, style, URI, data):
"""Callback function when a stylesheet using it is destroyed"""
pass
def ctxtInit(self, ctxt, URI):
"""Callback function when used in a new transformation process,
the return value is passed in subsequent calls"""
pass
def ctxtShutdown(self, ctxt, URI, data):
"""Callback function when a transformation using it finishes"""
pass
#
# Everything below this point is automatically generated
#