2.4 Handlers

Through the processor method regHandler(), you can register objects with sablotron that will be called to perform specific functions when You call then run() method. The interfaces for the four handler types (registered with the type values HLR_MESSAGE, HLR_MISC, HLR_SAX, HLR_SCHEME) are described below.

This example shows how to use the MiscHandler interface to print the conent type of the document created by Sablotron:


sp = Sablot.CreateProcessor()

class TestMiscHandler:
    def documentInfo(self, ctype, enc):
        print 'ContentType=%s, Encoding=%s' % (ctype, enc)

sp.regHandler(Sablot.HLR_MISC, TestMiscHandler())
sp.run('arg:sheet', url, 'arg:output', [], [('sheet', sheet)])


Subsections


Send comments to guenter@ubka.uni-karlsruhe.de.