velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Contexts and Profiling
Date Wed, 27 Nov 2002 17:45:48 GMT
I have created a context dump tool. See attachment.
I use a layout approach like turbine and the layout template does:

#if( $debug )
   #parse( "dump.vm" )

The debug flag is passed in as a query parameter and then cached in the
session attributes. This way I just have to switch on debugging and see
the dump attached to every page:
## ------------------------------------------------------------------------
## Decode dubug flag state
## ------------------------------------------------------------------------
## and save debug flag in session (not in the query string)
## get the debug flag state from the session (false is the default)
#set( $debug = false )
#set( $debug = $!app.get("debug") )
#if( !$debug )
   #set( $debug = false )
## overlay the debug flag with possible value from the QueryString
#set( $debug = $parameters.getBoolean("debug", $debug) )
## promote the state into the session
#call( $app.put("debug", $debug) )

This has worked nice for me. Some improvements are possile:
* Add a #context directive to put the current context into the context
   for dumping
* Add additional flags to tell the dumper to dump a specific object
   content or its API.
* Output other formats... (I got a version for plain text)


Michal Chmielewski wrote:
> Clear DayThe velocity context is map of keys to objects. These objects have
> methods and are possibly of quite varying complexity and are in fact the
> only "contract" between the code that prepares them for the template and the
> actual template.
> Anyone written a tool/template that could be used as an initial template
> that would show:
>   - all the context objects in the current context/parent context
>   - print out their public interfaces (ie. what the methods/fields are
> available to reference)
>   - allow for integration of this with javadoc or source browser.
> I am not talking here about an editor plugin of some sort, just a template
> that would dump out the current context and pretty print the
> objects/methods/fields of the context objects.
> The other topic is profiling. Does Velocity have anything like this ?
> -michal
> --
> To unsubscribe, e-mail:   <>
> For additional commands, e-mail: <>

:) Christoph Reck

View raw message