Selectors
=========

The selector is responsible for finding the nodes on which to operate.
Selectors are executed on the client. They need a name and an optional
parameter.

A base class is provided for all selectors.

  >>> from kss.base.selectors import Selector
  >>> selector = Selector('type', 'value')

The selector now has a type and value property.

  >>> selector.type
  'type'

  >>> selector.value
  'value'

Standard selectors
------------------

In the core package you can find a few standard selectors. The most
basic selectors are the CSS and HTML id selectors.

  >>> from kss.base.coreselectors import css, htmlid

They both need a value to operate on.

  >>> selector = css('div.main a')
  >>> selector.type
  'css'
  >>> selector.value
  'div.main a'

  >>> selector = htmlid('someid')
  >>> selector.type
  'htmlid'
  >>> selector.value
  'someid'
  
There are also two somewhat different selectors. The first is special
in that it selects the same node that was used to call the server
action. Also note that it does not accept any arguments.

  >>> from kss.base.coreselectors import samenode
  >>> selector = samenode()
  >>> selector.type
  'samenode'
  >>> selector.value
  ''

Another core selector is parentnode. This one can be used to use a CSS
query which only operates on nodes that are the parent (or
grandparents).

  >>> from kss.base.coreselectors import parentnode
  >>> selector = parentnode('a')
  >>> selector.type
  'parentnode'
  >>> selector.value
  'a'

String representation
---------------------

For testing purposes we have a string representation of the selectors.

!TODO: Fix lower casing of string representation

  >>> print Selector('type', 'value')
  type('value')

  >>> print css('div.content')
  css('div.content')
