| |
- PSPParser
- exceptions.Exception(exceptions.BaseException)
-
- PSPParserException
class PSPParser |
|
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 handle the current location in
the code. When it finds one, it calls a list of functions, the xxxChecks,
asking each if it recognizes the characters as its kind of input.
When the check functions 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 check function accepted. |
|
Methods defined here:
- __init__(self, ctxt)
- checkDirective(self, handler, reader)
- Check for directives. I support two right now, page and include.
- checkEndBlock(self, handler, reader)
- 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.
I 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.
<psp:class>
def foo(self):
return dosomething()
</psp:class>
- checkScriptFile(self, handler, reader)
- Check for file level code.
Check for Python code that should go in the beginning of the generated module.
<psp:file>
import xyz
print 'hi Mome!'
def foo(): return 'foo'
</psp:file>
- 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, accept=None)
- Parse the PSP file.
- setEventHandler(self, handler)
- Set the handler this parser will use when it finds PSP code.
Data and other attributes defined here:
- checklist = [<function commentCheck at 0x48d5e9cc>, <function checkExpression at 0x48d5eb1c>, <function checkDirective at 0x48d5e87c>, <function checkEndBlock at 0x48d5eaac>, <function checkScript at 0x48d5eae4>, <function checkScriptFile at 0x48d5ea74>, <function checkScriptClass at 0x48d5ea04>, <function checkMethod at 0x48d5e72c>, <function checkInclude at 0x48d5e844>, <function checkInsert at 0x48d5e8b4>]
|
|