File: hello.py

package info (click to toggle)
cocoon2 20010420-1
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 15,864 kB
  • ctags: 3,013
  • sloc: java: 18,267; xml: 7,879; sh: 86; makefile: 64; sql: 16; python: 16
file content (29 lines) | stat: -rw-r--r-- 752 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Sample python script for use with ScriptGenerator

# Step 1 -- Retrieve helper "beans" from the BSF framework

out      = bsf.lookupBean( "output" )
logger   = bsf.lookupBean( "logger" )
resolver = bsf.lookupBean( "resolver" )
source   = bsf.lookupBean( "source" )
objModel = bsf.lookupBean( "objectModel" )
params   = bsf.lookupBean( "parameters" )

# Step 2 -- Generate xml using whatever means you desire

xml="""
<page>
  <title>Hello</title>
  <content>
    <para>This is my first Cocoon2 page!</para>
    <para>With help from Python!</para>
  </content>
</page>"""

# note that you have access to the Cocoon logger

logger.debug( "Debug message from Python" )

# Step 3 -- Append the generated xml to the output StringBuffer

out.append( xml )