PSP.Generators
index
/usr/local/share/webware/PSP/Generators.py

Generate Python code from PSP templates.
 
This module holds the classes that generate the Python code resulting from the PSP template file.
As the parser encounters PSP elements, it creates a new Generator object for that type of element.
Each of these elements is put into a list maintained by the ParseEventHandler object.  When it comes
time to output the Source Code, each generator is called in turn to create it's source.
 
(c) Copyright by Jay Love, 2000 (mailto:jsliv@jslove.org)
 
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee or royalty is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation or portions thereof, including modifications,
that you make.
 
THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE !
 
This software is based in part on work done by the Jakarta group.

 
Modules
       
PSP.BraceConverter
PSP.PSPUtils
os
re

 
Classes
       
GenericGenerator
CharDataGenerator
EndBlockGenerator
ExpressionGenerator
IncludeGenerator
InsertGenerator
MethodEndGenerator
MethodGenerator
ScriptClassGenerator
ScriptFileGenerator
ScriptGenerator

 
class CharDataGenerator(GenericGenerator)
    This class handles standard character output, mostly HTML.
 
It just dumps it out. Need to handle all the escaping of characters.
It's just skipped for now.
 
  Methods defined here:
__init__(self, chars)
generate(self, writer, phase=None)
generateChunk(self, writer, start=0, stop=None)
mergeData(self, cdGen)

 
class EndBlockGenerator(GenericGenerator)
     Methods defined here:
__init__(self)
generate(self, writer, phase=None)

 
class ExpressionGenerator(GenericGenerator)
    This class handles expression blocks.
 
It simply outputs the (hopefully) python expression within the block
wrapped with a _formatter() call.
 
  Methods defined here:
__init__(self, chars)
generate(self, writer, phase=None)

 
class GenericGenerator
    Base class for the generators
 
  Methods defined here:
__init__(self, ctxt=None)

 
class IncludeGenerator(GenericGenerator)
    Handle psp:include directives.
 
This is a new version of this directive that actually
forwards the request to the specified page.
 
  Methods defined here:
__init__(self, attrs, param, ctxt)
generate(self, writer, phase=None)
Just insert theFunction.

 
class InsertGenerator(GenericGenerator)
    Include files designated by the psp:insert syntax.
 
If the attribute 'static' is set to True or 1, we include the file now,
at compile time. Otherwise, we use a function added to every PSP page
named __includeFile, which reads the file at run time.
 
  Methods defined here:
__init__(self, attrs, param, ctxt)
generate(self, writer, phase=None)

 
class MethodEndGenerator(GenericGenerator)
    Part of class method generation.
 
After MethodGeneratorMethodEndGenerator actually generates
the code for the method body.
 
  Methods defined here:
__init__(self, chars, attrs)
generate(self, writer, phase=None)

 
class MethodGenerator(GenericGenerator)
    Generate class methods defined in the PSP page.
 
There are two parts to method generation.
This class handles getting the method name and parameters set up.
 
  Methods defined here:
__init__(self, chars, attrs)
generate(self, writer, phase=None)

 
class ScriptClassGenerator(GenericGenerator)
    Add Python code at the class level.
 
  Methods defined here:
__init__(self, chars, attrs)
generate(self, writer, phase=None)

 
class ScriptFileGenerator(GenericGenerator)
    Add Python code at the file/module level.
 
  Methods defined here:
__init__(self, chars, attrs)
generate(self, writer, phase=None)

 
class ScriptGenerator(GenericGenerator)
    Generate scripts.
 
  Methods defined here:
__init__(self, chars, attrs)
generate(self, writer, phase=None)

 
Data
        AwakeCreated = 0
ResponseObject = 'res'