|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsunlabs.brazil.template.Template
sunlabs.brazil.python.PythonServerTemplate (view source)
public class PythonServerTemplate
The PythonServerTemplate
looks for each
<server language="python">
(or
<python>
)
tag in an HTML page and treats the following data up to the next
</server>
(or </python>
)
tag as a python script to evaluate.
The reason that python scripts are included in an HTML page is usually
to generate dynamic, server-side content. After running this template,
everything between and including the <server>
and
</server>
(or <python>
and
</python>
tags is replaced by all output written
to the Python standard output stream (if any).
All Python fragments within a given page are evaluated in the same Python
interpreter. The Python interpreter actually lives for the entire duration
of this Template
object, so the user can implement
persistence across requests.
The following configuration parameters are used to initialize this template.
prefix
and
server
are set before this file is evaluated, and
are references to the parameters passed to a handler
init method.
<server>
and
</server>
tags with comments, so the user
can keep track of where the dynamically generated content is coming
from by examining the comments in the resultant HTML document.
By default, the <server>
and
</server>
are completely eliminated from the
HTML document rather than changed into comments.
Before evaluating each HTML document, this class sets variables in the Python interpreter, which can be used to interact back with Java to do things like set the response headers:
Request
Java object.
It is set anew at each request.
Server
object.
eval
is present as an attribute, all
constructs off the form ${...} are substituted before processing the
script.
Field Summary |
---|
Fields inherited from class sunlabs.brazil.template.Template |
---|
debug |
Constructor Summary | |
---|---|
PythonServerTemplate()
|
Method Summary | |
---|---|
boolean |
init(RewriteContext hr)
Called before this template processes any tags. |
void |
tag_python(RewriteContext hr)
Processes the <python> tag. |
void |
tag_server(RewriteContext hr)
Processes the <server> tag. |
Methods inherited from class sunlabs.brazil.template.Template |
---|
done |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PythonServerTemplate()
Method Detail |
---|
public boolean init(RewriteContext hr)
Template
init
in interface TemplateInterface
init
in class Template
public void tag_server(RewriteContext hr)
<server>
tag. Substitues the
result of evaluating the following Python script into the resultant
HTML document.
Note: Currently, there is no mechanism for other language interpreters
to share the same server
tag.
hr
- The request and associated HTML document that will be
processed.public void tag_python(RewriteContext hr)
<python>
tag. Substitues the
result of evaluating the following Python script into the resultant
HTML document.
hr
- The request and associated HTML document that will be
processed.
|
Version Kenai-svn-r24, Generated 08/18/09 Copyright (c) 2001-2009, Sun Microsystems. |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |