Python (Jepp) Scriptlet Example

<%jepp # # Defer this page # if str(conversation.getQuery().get('defer')) == 'true': if conversation.defer(): conversation.stop() # # Cache this page # caching.setDuration(5000) # # Calling Java # from java.lang import * sys.stdout.write('

This page was dynamically generated at %s

' % System.currentTimeMillis()) # (Note: Python's print statement can be used here, too, but it may not be the best choice # for outputting HTML due to its "softspace" feature. It is meant more for debugging than # for clean output. Also, it is no longer supported in Python 3. We'll prefer sys.stdout # in this example.) # # An example of a method # def print_adapter(adapter): %>

Adapter: <%= adapter.getAttributes().get('name') %> version <%= adapter.getAttributes().get('version') %>
Language: <%= adapter.getAttributes().get('language.name') %> version <%= adapter.getAttributes().get('language.version') %>
Tags: <% tags = adapter.getAttributes().get('tags').toArray() for i in range(len(tags)): sys.stdout.write(str(tags[i])) if i < len(tags) - 1: sys.stdout.write(', ') %>

<% %>

Language used:

<% print_adapter(executable.getContext().getAdapter()) %>

Available languages:

<% adapters = executable.getManager().getAdapters().toArray() for adapter in adapters: print_adapter(adapter) %>

The "id" attribute in the URL query is:

<%= conversation.getQuery().get('id') or '' %>

A few tests:

<% # # Including a document # # This is identical to: # # document.include('/triple/python-jepp/') # %> <%& '/triple/python-jepp/' %> <% for i in range(10): %>A multiple of three: <% print_triple(i) %>
<% %>