sqlite3 support unicode

set text_factory to unicode and then the sqlite3 module will return
Unicode objects for TEXT
ref: http://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.text_factory

Also update the test case for unicode test.

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Reviewed-by: Adam Litke <agl@linux.vnet.ibm.com>
Reviewed-by: Aline Manera <alinefm@linux.vnet.ibm.com>
Reviewed-by : Meina Zhou <zhoumein@linux.vnet.ibm.com>
Reviewed-by: Hongliang Wang <hlwang@linux.vnet.ibm.com>
Tested-by: Hongliang Wang <hlwang@linux.vnet.ibm.com>
support create a vm with unicode name

One principle:
We should audit the code in order to properly handle unicode throughout.
This means always calling var.decode('utf-8') on incoming text and
var.encode('utf-8') on outgoing text.

For incoming text:
The json body from the UI client is unicode, is decoded by incoming
filter (parse_request).
The URL from the UI client is str, need decode.
The text form libvirt is str, need decode.

For outgoing text:
Outgoing text to libvirt, such as xml or VM name should be encode.
Outgoing text to UI should be encode by template render.

At last we should achieve:
All text strings, everywhere should be of type unicode, not str.
If you're handling text, and your variable is a str, it's a bug!

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com>
Reviewed-by: Aline Manera <alinefm@linux.vnet.ibm.com>
Reviewed-by: Hongliang Wang <hlwang@linux.vnet.ibm.com>
Tested-by: Hongliang Wang <hlwang@linux.vnet.ibm.com>
mockmodel support a VM with ww language name

principle:
   We should audit the code in order to properly handle unicode throughout.
   This means always calling var.decode('utf-8') on incoming text and
   var.encode('utf-8') on outgoing text.

   All text strings in other code should be of type unicode, not str.

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
test case for creating a vm with unicode name

Make sure we can create a vm with unicode name.

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Reviewed-by: Aline Manera <alinefm@linux.vnet.ibm.com>
Reviewed-by: Hongliang Wang <hlwang@linux.vnet.ibm.com>
Tested-by: Hongliang Wang <hlwang@linux.vnet.ibm.com>
Using absolute path in error page

Error page will be returned for URI deeper than one layer of directory,
such as: http://localhost:8000/d1/d2/non-existent-page.html
Using relative path will result in img and css not found.
Change reference to be absolute path.

Signed-off-by: Bing Bu Cao <mars@linux.vnet.ibm.com>
Signed-off-by: Royce Lv <lvroyce@linux.vnet.ibm.com>
python2.6 do not support dict key iteration

python2.6 do not support dict key iteration

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Signed-off-by: zhoumeina <zhoumein@linux.vnet.ibm.com>
ui: Rename tab pages

We now have bookmarkable tabs using hash '#' in the kimchi URL.
Unfortunately the tab names are not consistent (due to inconsistent html
file names).  To correct the tab names, rename the underlying html files
consistently.

Signed-off-by: Adam Litke <agl@linux.vnet.ibm.com>
Issue #39: Animate Button Clicks to Provide User Feedback

V1 -> V2:
    1) Remove styles for disabled button.
    2) Add styles for .btn-normal.

Users expect visual effect when they rollover or click a button. In
this patch, we added CSS rules for 2 button states: rollover(:hover)
and click(:active).

    Tested on Firefox 22, Chrome, Safari, Opera, IE9, and IE10.

Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com>
i18n: Stop adding location comments to po files

Each time the po files are regenerated xgettext adds location
information for each translation string.  Given our method of feeding
xgettext from stdin, this information is useless.  By passing
--no-location to the invocation of xgettext we will suppress the extra
output.  Once applied, future i18n patches will not introduce so much
noise and it will be easier to see what was actually changed.

Signed-off-by: Adam Litke <agl@linux.vnet.ibm.com>
Reviewed-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Remove magic directories from config.py.in

V1->V2:
 - Put the correct default log directory in the config file

Now that we are using autotools to build our source, we have actual
variables to indicate the proper directories for logs, config files, and
package data.  Use the provided variables so that we will run properly
if the user customizes them.

Signed-off-by: Adam Litke <agl@linux.vnet.ibm.com>
Add Portuguese (Brazil) translation

That way Kimchi can show UI in Portuguese (Brazil).

Signed-off-by: Aline Manera <alinefm@br.ibm.com>
issue #82: convert from svg image to png image

SVG is Scalable Vector Graphics image, but it can not supported by
IE.

issue: https://github.com/kimchi-project/kimchi/issues/82

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Signed-off-by: zhoumeina <zhoumein@linux.vnet.ibm.com>
IE8: Very long guest names cause column misalignment

Very long guest names cause column misalignment in IE8.
The issues #10 described the same problem, but this was not fixed in IE8.

Signed-off-by: Xin Ding <xinding@linux.vnet.ibm.com>
issues #95: Added files generated by build to .gitignore

git status reports a number of files as modified that are generated
by the runtime or build. Adding this files to ignore more of them.

issues: https://github.com/kimchi-project/kimchi/issues/95

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Add delete confirm message box

v2->v3 Rebase the code
v1->v2 Change some message translations in po files.
       Make the confirm button text and cancel button
       text parameters, so that the message box can be
       used more widely.
1 Add a delete confirm message box when
delete template and vm.
issue:https://github.com/kimchi-project/kimchi/issues/85

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Signed-off-by: zhoumeina <zhoumein@linux.vnet.ibm.com>

Reviewed-by: Hongliang Wang <hlwang@linux.vnet.ibm.com>
Reviewed-by : Xin Ding <xinding@linux.vnet.ibm.com>
IE8: The template list page can't be displayed

The template list page can't be displayed in IE8. When clicking
the template in the menu bar, an empty page was showed.

This is because an additional div end tag '</div>' in the page
makes IE8 to stop rendering the whole page.

Signed-off-by: Xin Ding <xinding@linux.vnet.ibm.com>
codingstyle: Fix indent for templates.html.tmpl

We just merged a fix to templates.html.tmpl where we had an extra </div>
tag.  These errors are made more common by code that isn't properly
indented.  Fix this file to make it easier to see the nesting of the
document.  All tabs have been replaced with 4 spaces as per community
style guidelines.

Signed-off-by: Adam Litke <agl@linux.vnet.ibm.com>
template-update: define an update method in API.md document

Define an PUT method for template update

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
template-update: resouce support update method

add PUT method for Resouce class
implement update attribute for sub-class Template

We need a common of update method.
We should also support edit the name of resource.
If we edit the name of resource, we had better raise a 301 redirection,
that means the resource is moved permanent.

add a field 'uri_fmt' that each Resource instance needs to define that
can construct the redirect uri:
self.uri_fmt = "/Collections/%s/Collections/%s"

Then in the common redirect we can just do:
raise cherrypy.HTTPRedirect(self.uri_fmt % tuple(list(self.model_args[:-1])
                            + [ident]). 301)

In the code of kimchi, somewhere, the self.model_args is defined as
list, and somewhere it is defined tuple.
so we should change it to list: list(self.model_args[:-1])

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
template-update: mock model support implement update method

implement template_update by calling template_delete followed by
template_create.
As Adam Litke suggested: save the original template so update will
rollback if something fails.

In mockmodel the info of template is stored in memory.
So the update can be this process: lookup -> copy -> delete -> create.
But this process can not by apply to VM create.
There is some specific data for a VM and we can't simply delete it and
then recreate it.

We should support this template update first, and then support VM update.

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>