Shortcuts
=========



Rendering commands to a response
================================

A KSS response is a pretty basic thing. It contains the data from the
commands object and sets the content type. To make this even easier
there is a shortcut to do all this.

  >>> from kss.django import kss_response

Lets start with a commands object.

  >>> from kss.base import KSSCommands
  >>> commands = KSSCommands()

Now we can render it to a response.

  >>> response = kss_response(commands)

This will create a response object with the headers we need.

  >>> response.items()
  [('Content-Type', 'text/xml')]
  
It also sets the payload to the rendered version of the commands.

  >>> response.content
  '...<kukit xmlns="http://www.kukit.org/commands/...">...'


KSS views
=========

Each KSS view will need to create a commands object and render it. To
make this process easier we have a shortcut. This is a decorator which
creates the commands object and renders it at the end.

The code below demonstrates its basic usage.

  >>> from kss.django import kss_view
  
  >>> @kss_view
  ... def some_view(request, commands):
  ...     commands.add('testing', '.selector', value='some value')

If we run this code we should get a proper response object. Notice
that we don't supply the commands parameter, this will be set by the
decorator.

  >>> response = some_view(None)
  >>> response
  <django.http.HttpResponse object at ...>

  >>> response.content
  '...<kukit xmlns="http://www.kukit.org/commands/...">...'
