Unify Parsers and Processors

Parsers and Processors in the last versions had different interfaces. There was one processor, python, which just called the python parser to do stuff. Then the CodeBlockColorizer was added, which is a generic processor that allows the use of all installed parsers as an processor (i.e. apply the parser to a pre block on the page).

For me this means: there isn't really a difference between Parser and Processor anymore, so why keep them separated?

Porting Processors

The interface is a bit different. A processor is just a function, a Parser needs to be a class.

Example:

   1 Dependencies = ["time"]
   2 
   3 class Parser:
   4     """ a noop parser """
   5 
   6     def __init__(self, raw, request):
   7         # save call arguments for later use in format
   8         self.raw = raw
   9         self.request = request
  10 
  11     def format(self, formatter):
  12         # this has the function of the old processor method
  13         # just use self.raw and self.request
  14         self.request.write(self.raw)

So you could just use this skeleton and put the code of the old processor (if it is a single function processor) into the format method of the Parser class.

MoinMoin: UnifyParsersAndProcessors (last edited 2007-10-29 19:13:45 by localhost)