cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stev...@outerthought.org
Subject [WIKI-UPDATE] Snippets PythonScriptGenerator Fri Dec 19 13:00:03 2003
Date Fri, 19 Dec 2003 12:00:03 GMT
Page: http://wiki.cocoondev.org/Wiki.jsp?page=Snippets , version: 29 on Fri Dec 19 12:08:13
2003 by LaurentMauron

+ 
+ !Custom generator in Python
+ See [PythonScriptGenerator]


Page: http://wiki.cocoondev.org/Wiki.jsp?page=PythonScriptGenerator , version: 1 on Fri Dec
19 12:11:15 2003 by LaurentMauron

New page created:
+ #Download and copy jython.jar in web-inf directory.
+ #Sitemap pipeline:
+ 	{{{<map:match pattern="test.py">
+ 		<map:generate src="test.py" type="script">
+ 			<map:parameter name="key" value="Shark Attack"/>
+ 		</map:generate>
+ 		<map:serialize type="xml"/>
+ </map:match>}}}
+ #Python script:
+ {{{import os
+ 
+ #get the output String buffer 
+ output	     = bsf.lookupBean( "output" )
+ 
+ #get the Parameters object
+ parameters   = bsf.lookupBean("parameters")
+ 
+ 
+ #get the value of the parameter "key" defined in the sitemap
+ value = parameters.getParameter("key")
+ 
+ #generate xml
+ output.append("<msg>" + value +"</msg>")}}}
+ 



Mime
View raw message