||The main PSP parser class.|
The PSPParser class does the actual sniffing through the input file
looking for anything we're interested in. Basically, it starts by
looking at the code looking for a '<' symbol. It looks at the code by
working with a PSPReader object, which handles the current location in
the code. When it finds one, it calls a list of checker methods,
asking each if it recognizes the characters as its kind of input.
When the checker methods look at the characters, if they want it,
they go ahead and gobble it up and set up to create it in the servlet
when the time comes. When they return, they return true if they accept
the character, and the PSPReader object cursor is positioned past the
end of the block that the checker method accepted.
||Methods defined here:|
- __init__(self, ctxt)
- checkDirective(self, handler, reader)
- Check for directives; for now we support only page and include.
- checkEndBlock(self, handler, reader)
- Check for the end of a block.
- checkExpression(self, handler, reader)
- Look for "expressions" and handle them.
- checkInclude(self, handler, reader)
- Check for inserting another pages output in this spot.
- checkInsert(self, handler, reader)
- Check for straight character dumps.
No big hurry for this. It's almost the same as the page include
directive. This is only a partial implementation of what JSP does.
JSP can pull it from another server, servlet, JSP page, etc.
- checkMethod(self, handler, reader)
- Check for class methods defined in the page.
We only support one format for these,
<psp:method name="xxx" params="xxx,xxx">
Then the function body, then </psp:method>.
- checkScript(self, handler, reader)
- The main thing we're after. Check for embedded scripts.
- checkScriptClass(self, handler, reader)
- Check for class level code.
Check for Python code that should go in the class definition.
- checkScriptFile(self, handler, reader)
- Check for file level code.
Check for Python code that should go to the top of the generated module.
print 'hi Mome!'
def foo(): return 'foo'
- commentCheck(self, handler, reader)
- Comments just get eaten.
- flushCharData(self, start, stop)
- Dump everything to the char data handler.
Dump all the HTML that we've accumulated over to the character data
handler in the event handler object.
- parse(self, until=None)
- Parse the PSP file.
- setEventHandler(self, handler)
- Set the handler this parser will use when it finds PSP code.
Data descriptors defined here:
- dictionary for instance variables (if defined)
- list of weak references to the object (if defined)
Data and other attributes defined here:
- checklist = [<function commentCheck>, <function checkExpression>, <function checkDirective>, <function checkEndBlock>, <function checkScript>, <function checkScriptFile>, <function checkScriptClass>, <function checkMethod>, <function checkInclude>, <function checkInsert>]