[Zope3-Users] Inline code in ZPT

Florian Lindner mailinglists at xgm.de
Wed Jul 6 16:28:58 EDT 2005


Am Mittwoch, 6. Juli 2005 21:47 schrieb Nicolas Legault:
> Two questions:
>
> 1:
> Is it possible to have Inline code in a page template that is created on
> the host file system, not throught the ZMI ? I got an error that inline
> code is not activated, where do I activate it ?
>
> 2:
> Is it a bug or this code is now not supported in Zope 3.1 ZPT ?
>
>           01 <html><body>
>           02   <script type="text/server-python">
>           03     global x
>           04     x = "Hello World!"
>           05   </script>
>           06   <b tal:content="x" />
>           07 </body></html>
> this code is from
> http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/Zope3GUI

I don't know if it is still possible.
>
> If it's not supported anymore, is there a way to return values from the
> python script and use them in the zpt ?

You can always define a view class and use the return value of a function:

<browser:page
	template="the_file_above.zpt"
	class="pyfile.viewclass"
	[...] />

In your file pyfile:

class viewclass:
	def foo(self):
		return "bar"

and now you can use a TAL expression like that:

<span tal:replace="view/foo" />

is being replaced with:

bar


Hope that helps,

Florian


More information about the Zope3-users mailing list