[Ovirt-devel] [PATCH] Provides a reference implementation management server.

David Huff dhuff at redhat.com
Fri Feb 12 21:48:15 UTC 2010


ACK

On 02/11/2010 12:52 PM, Darryl L. Pierce wrote:
> The reference implementation server is based on TG2. The majority of the
> boiler plate code has been stripped out to focus the server solely on
> the functionality necessary for a management server.
>
> Signed-off-by: Darryl L. Pierce<dpierce at redhat.com>
> ---
>   server/.gitignore                                  |    4 +
>   server/MANIFEST.in                                 |    4 +
>   server/README.txt                                  |   24 ++
>   server/development.ini                             |  130 ++++++++++
>   server/ez_setup/README.txt                         |   14 ++
>   server/ez_setup/__init__.py                        |  247 ++++++++++++++++++++
>   server/ovirtserver/__init__.py                     |   18 ++
>   server/ovirtserver/config/__init__.py              |   16 ++
>   server/ovirtserver/config/app_cfg.py               |   54 +++++
>   server/ovirtserver/config/deployment.ini_tmpl      |  104 ++++++++
>   server/ovirtserver/config/environment.py           |   25 ++
>   server/ovirtserver/config/middleware.py            |   55 +++++
>   server/ovirtserver/controllers/__init__.py         |   18 ++
>   server/ovirtserver/controllers/controller.template |   36 +++
>   server/ovirtserver/controllers/error.py            |   46 ++++
>   server/ovirtserver/controllers/root.py             |   55 +++++
>   server/ovirtserver/controllers/secure.py           |   21 ++
>   server/ovirtserver/controllers/template.py         |   51 ++++
>   .../ovirtserver/i18n/ru/LC_MESSAGES/ovirtserver.po |   24 ++
>   server/ovirtserver/lib/__init__.py                 |   16 ++
>   server/ovirtserver/lib/app_globals.py              |   33 +++
>   server/ovirtserver/lib/base.py                     |   44 ++++
>   server/ovirtserver/lib/helpers.py                  |   20 ++
>   server/ovirtserver/model/__init__.py               |   77 ++++++
>   server/ovirtserver/model/auth.py                   |   27 +++
>   server/ovirtserver/model/model.template            |   37 +++
>   server/ovirtserver/public/favicon.ico              |  Bin 0 ->  1104 bytes
>   server/ovirtserver/templates/__init__.py           |   18 ++
>   server/ovirtserver/templates/error.html            |   19 ++
>   server/ovirtserver/templates/index.html            |   20 ++
>   server/ovirtserver/tests/__init__.py               |   80 +++++++
>   server/ovirtserver/tests/functional/__init__.py    |   18 ++
>   .../tests/functional/test_authentication.py        |   16 ++
>   server/ovirtserver/tests/functional/test_root.py   |   48 ++++
>   server/ovirtserver/tests/models/__init__.py        |   68 ++++++
>   server/ovirtserver/tests/models/test_auth.py       |   22 ++
>   server/ovirtserver/websetup.py                     |   42 ++++
>   server/server.egg-info/PKG-INFO                    |   10 +
>   server/server.egg-info/SOURCES.txt                 |   68 ++++++
>   server/server.egg-info/dependency_links.txt        |    1 +
>   server/server.egg-info/entry_points.txt            |    7 +
>   server/server.egg-info/paster_plugins.txt          |    4 +
>   server/server.egg-info/requires.txt                |    6 +
>   server/server.egg-info/top_level.txt               |    1 +
>   server/setup.cfg                                   |   32 +++
>   server/setup.py                                    |   63 +++++
>   server/test.ini                                    |   42 ++++
>   47 files changed, 1785 insertions(+), 0 deletions(-)
>   create mode 100644 server/.gitignore
>   create mode 100644 server/MANIFEST.in
>   create mode 100644 server/README.txt
>   create mode 100644 server/development.ini
>   create mode 100644 server/ez_setup/README.txt
>   create mode 100644 server/ez_setup/__init__.py
>   create mode 100644 server/ovirtserver/__init__.py
>   create mode 100644 server/ovirtserver/config/__init__.py
>   create mode 100644 server/ovirtserver/config/app_cfg.py
>   create mode 100644 server/ovirtserver/config/deployment.ini_tmpl
>   create mode 100644 server/ovirtserver/config/environment.py
>   create mode 100644 server/ovirtserver/config/middleware.py
>   create mode 100644 server/ovirtserver/controllers/__init__.py
>   create mode 100644 server/ovirtserver/controllers/controller.template
>   create mode 100644 server/ovirtserver/controllers/error.py
>   create mode 100644 server/ovirtserver/controllers/root.py
>   create mode 100644 server/ovirtserver/controllers/secure.py
>   create mode 100644 server/ovirtserver/controllers/template.py
>   create mode 100644 server/ovirtserver/i18n/ru/LC_MESSAGES/ovirtserver.po
>   create mode 100644 server/ovirtserver/lib/__init__.py
>   create mode 100644 server/ovirtserver/lib/app_globals.py
>   create mode 100644 server/ovirtserver/lib/base.py
>   create mode 100644 server/ovirtserver/lib/helpers.py
>   create mode 100644 server/ovirtserver/model/__init__.py
>   create mode 100644 server/ovirtserver/model/auth.py
>   create mode 100644 server/ovirtserver/model/model.template
>   create mode 100644 server/ovirtserver/public/favicon.ico
>   create mode 100644 server/ovirtserver/templates/__init__.py
>   create mode 100644 server/ovirtserver/templates/error.html
>   create mode 100644 server/ovirtserver/templates/index.html
>   create mode 100644 server/ovirtserver/tests/__init__.py
>   create mode 100644 server/ovirtserver/tests/functional/__init__.py
>   create mode 100644 server/ovirtserver/tests/functional/test_authentication.py
>   create mode 100644 server/ovirtserver/tests/functional/test_root.py
>   create mode 100644 server/ovirtserver/tests/models/__init__.py
>   create mode 100644 server/ovirtserver/tests/models/test_auth.py
>   create mode 100644 server/ovirtserver/websetup.py
>   create mode 100644 server/server.egg-info/PKG-INFO
>   create mode 100644 server/server.egg-info/SOURCES.txt
>   create mode 100644 server/server.egg-info/dependency_links.txt
>   create mode 100644 server/server.egg-info/entry_points.txt
>   create mode 100644 server/server.egg-info/paster_plugins.txt
>   create mode 100644 server/server.egg-info/requires.txt
>   create mode 100644 server/server.egg-info/top_level.txt
>   create mode 100644 server/setup.cfg
>   create mode 100644 server/setup.py
>   create mode 100644 server/test.ini
>
> diff --git a/server/.gitignore b/server/.gitignore
> new file mode 100644
> index 0000000..41bf6ae
> --- /dev/null
> +++ b/server/.gitignore
> @@ -0,0 +1,4 @@
> +build/
> +data/
> +dist/
> +devdata.db
> diff --git a/server/MANIFEST.in b/server/MANIFEST.in
> new file mode 100644
> index 0000000..e9c47eb
> --- /dev/null
> +++ b/server/MANIFEST.in
> @@ -0,0 +1,4 @@
> +recursive-include ovirtserver/public *
> +include ovirtserver/public/favicon.ico
> +recursive-include ovirtserver/i18n *
> +recursive-include ovirtserver/templates *
> diff --git a/server/README.txt b/server/README.txt
> new file mode 100644
> index 0000000..809ebf3
> --- /dev/null
> +++ b/server/README.txt
> @@ -0,0 +1,24 @@
> +This file is for you to describe the server application. Typically
> +you would include information such as the information below:
> +
> +Installation and Setup
> +======================
> +
> +Install ``server`` using the setup.py script::
> +
> +    $ cd server
> +    $ python setup.py install
> +
> +Create the project database for any model classes defined::
> +
> +    $ paster setup-app development.ini
> +
> +Start the paste http server::
> +
> +    $ paster serve development.ini
> +
> +While developing you may want the server to reload after changes in package files (or its dependencies) are saved. This can be achieved easily by adding the --reload option::
> +
> +    $ paster serve --reload development.ini
> +
> +Then you are ready to go.
> diff --git a/server/development.ini b/server/development.ini
> new file mode 100644
> index 0000000..2295b25
> --- /dev/null
> +++ b/server/development.ini
> @@ -0,0 +1,130 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +[DEFAULT]
> +debug = true
> +# Uncomment and replace with the address which should receive any error reports
> +#email_to = you at yourdomain.com
> +smtp_server = localhost
> +error_email_from = paste at localhost
> +
> +[server:main]
> +use = egg:Paste#http
> +host = 127.0.0.1
> +port = 8080
> +
> +[app:main]
> +use = egg:server
> +full_stack = true
> +#lang = ru
> +cache_dir = %(here)s/data
> +beaker.session.key = ovirtserver
> +beaker.session.secret = somesecret
> +
> +# If you'd like to fine-tune the individual locations of the cache data dirs
> +# for the Cache data, or the Session saves, un-comment the desired settings
> +# here:
> +#beaker.cache.data_dir = %(here)s/data/cache
> +#beaker.session.data_dir = %(here)s/data/sessions
> +
> +# pick the form for your database
> +# %(here) may include a ':' character on Windows environments; this can
> +# invalidate the URI when specifying a SQLite db via path name
> +# sqlalchemy.url=postgres://username:password@hostname:port/databasename
> +# sqlalchemy.url=mysql://username:password@hostname:port/databasename
> +
> +
> +# If you have sqlite, here's a simple default to get you started
> +# in development
> +
> +sqlalchemy.url = sqlite:///%(here)s/devdata.db
> +#echo shouldn't be used together with the logging module.
> +sqlalchemy.echo = false
> +sqlalchemy.echo_pool = false
> +sqlalchemy.pool_recycle = 3600
> +
> +# if you are using Mako and want to be able to reload
> +# the mako template from disk during the development phase
> +# you should say 'true' here
> +# This option is only used for mako templating engine
> +# WARNING: if you want to deploy your application using a zipped egg
> +# (ie: if your application's setup.py defines zip-safe=True, then you
> +# MUST put "false" for the production environment because there will
> +# be no disk and real files to compare time with.
> +# On the contrary if your application defines zip-safe=False and is
> +# deployed in an unzipped manner, then you can leave this option to true
> +templating.mako.reloadfromdisk = true
> +
> +# the compiled template dir is a directory that must be readable by your
> +# webserver. It will be used to store the resulting templates once compiled
> +# by the TemplateLookup system.
> +# During development you generally don't need this option since paste's HTTP
> +# server will have access to you development directories, but in production
> +# you'll most certainly want to have apache or nginx to write in a directory
> +# that does not contain any source code in any form for obvious security reasons.
> +#
> +#templating.mako.compiled_templates_dir = /some/dir/where/webserver/has/access
> +
> +# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
> +# Debug mode will enable the interactive debugging tool, allowing ANYONE to
> +# execute malicious code after an exception is raised.
> +#set debug = false
> +
> +# Logging configuration
> +# Add additional loggers, handlers, formatters here
> +# Uses python's logging config file format
> +# http://docs.python.org/lib/logging-config-fileformat.html
> +
> +[loggers]
> +keys = root, ovirtserver, sqlalchemy
> +
> +[handlers]
> +keys = console
> +
> +[formatters]
> +keys = generic
> +
> +# If you create additional loggers, add them as a key to [loggers]
> +[logger_root]
> +level = INFO
> +handlers = console
> +
> +[logger_ovirtserver]
> +level = DEBUG
> +handlers =
> +qualname = ovirtserver
> +
> +[logger_sqlalchemy]
> +level = INFO
> +handlers =
> +qualname = sqlalchemy.engine
> +# "level = INFO" logs SQL queries.
> +# "level = DEBUG" logs SQL queries and results.
> +# "level = WARN" logs neither.  (Recommended for production systems.)
> +
> +
> +# If you create additional handlers, add them as a key to [handlers]
> +[handler_console]
> +class = StreamHandler
> +args = (sys.stderr,)
> +level = NOTSET
> +formatter = generic
> +
> +# If you create additional formatters, add them as a key to [formatters]
> +[formatter_generic]
> +format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
> +datefmt = %H:%M:%S
> diff --git a/server/ez_setup/README.txt b/server/ez_setup/README.txt
> new file mode 100644
> index 0000000..77c986d
> --- /dev/null
> +++ b/server/ez_setup/README.txt
> @@ -0,0 +1,14 @@
> +This directory exists so that Subversion-based projects can share a single
> +copy of the ``ez_setup`` bootstrap module for ``setuptools``, and have it
> +automatically updated in their projects when ``setuptools`` is updated.
> +
> +For your convenience, you may use the following svn:externals definition::
> +
> +    ez_setup svn://svn.eby-sarna.com/svnroot/ez_setup
> +
> +You can set this by executing this command in your project directory::
> +
> +    svn propedit svn:externals .
> +
> +And then adding the line shown above to the file that comes up for editing.
> +Then, whenever you update your project, ``ez_setup`` will be updated as well.
> diff --git a/server/ez_setup/__init__.py b/server/ez_setup/__init__.py
> new file mode 100644
> index 0000000..8d35412
> --- /dev/null
> +++ b/server/ez_setup/__init__.py
> @@ -0,0 +1,247 @@
> +#!python
> +#
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Bootstrap setuptools installation
> +
> +If you want to use setuptools in your package's setup.py, just include this
> +file in the same directory with it, and add this to the top of your setup.py::
> +
> +    from ez_setup import use_setuptools
> +    use_setuptools()
> +
> +If you want to require a specific version of setuptools, set a download
> +mirror, or use an alternate download directory, you can do so by supplying
> +the appropriate options to ``use_setuptools()``.
> +
> +This file can also be run as a script to install or upgrade setuptools.
> +"""
> +import sys
> +DEFAULT_VERSION = "0.6c7"
> +DEFAULT_URL     = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3]
> +
> +md5_data = {
> +    'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
> +    'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
> +    'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
> +    'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
> +    'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
> +    'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
> +    'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
> +    'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
> +    'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
> +    'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
> +    'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
> +    'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
> +    'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
> +    'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
> +    'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
> +    'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f',
> +    'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2',
> +    'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc',
> +    'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167',
> +    'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64',
> +    'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d',
> +    'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20',
> +    'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab',
> +    'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53',
> +    'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2',
> +    'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e',
> +    'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372',
> +}
> +
> +import sys, os
> +
> +def _validate_md5(egg_name, data):
> +    if egg_name in md5_data:
> +        from md5 import md5
> +        digest = md5(data).hexdigest()
> +        if digest != md5_data[egg_name]:
> +            print>>sys.stderr, (
> +                "md5 validation of %s failed!  (Possible download problem?)"
> +                % egg_name
> +            )
> +            sys.exit(2)
> +    return data
> +
> +
> +def use_setuptools(
> +    version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
> +    download_delay=15
> +):
> +    """Automatically find/download setuptools and make it available on sys.path
> +
> +    `version` should be a valid setuptools version number that is available
> +    as an egg for download under the `download_base` URL (which should end with
> +    a '/').  `to_dir` is the directory where setuptools will be downloaded, if
> +    it is not already available.  If `download_delay` is specified, it should
> +    be the number of seconds that will be paused before initiating a download,
> +    should one be required.  If an older version of setuptools is installed,
> +    this routine will print a message to ``sys.stderr`` and raise SystemExit in
> +    an attempt to abort the calling script.
> +    """
> +    try:
> +        import setuptools
> +        if setuptools.__version__ == '0.0.1':
> +            print>>sys.stderr, (
> +            "You have an obsolete version of setuptools installed.  Please\n"
> +            "remove it from your system entirely before rerunning this script."
> +            )
> +            sys.exit(2)
> +    except ImportError:
> +        egg = download_setuptools(version, download_base, to_dir, download_delay)
> +        sys.path.insert(0, egg)
> +        import setuptools; setuptools.bootstrap_install_from = egg
> +
> +    import pkg_resources
> +    try:
> +        pkg_resources.require("setuptools>="+version)
> +
> +    except pkg_resources.VersionConflict, e:
> +        # XXX could we install in a subprocess here?
> +        print>>sys.stderr, (
> +            "The required version of setuptools (>=%s) is not available, and\n"
> +            "can't be installed while this script is running. Please install\n"
> +            " a more recent version first.\n\n(Currently using %r)"
> +        ) % (version, e.args[0])
> +        sys.exit(2)
> +
> +def download_setuptools(
> +    version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
> +    delay = 15
> +):
> +    """Download setuptools from a specified location and return its filename
> +
> +    `version` should be a valid setuptools version number that is available
> +    as an egg for download under the `download_base` URL (which should end
> +    with a '/'). `to_dir` is the directory where the egg will be downloaded.
> +    `delay` is the number of seconds to pause before an actual download attempt.
> +    """
> +    import urllib2, shutil
> +    egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
> +    url = download_base + egg_name
> +    saveto = os.path.join(to_dir, egg_name)
> +    src = dst = None
> +    if not os.path.exists(saveto):  # Avoid repeated downloads
> +        try:
> +            from distutils import log
> +            if delay:
> +                log.warn("""
> +---------------------------------------------------------------------------
> +This script requires setuptools version %s to run (even to display
> +help).  I will attempt to download it for you (from
> +%s), but
> +you may need to enable firewall access for this script first.
> +I will start the download in %d seconds.
> +
> +(Note: if this machine does not have network access, please obtain the file
> +
> +   %s
> +
> +and place it in this directory before rerunning this script.)
> +---------------------------------------------------------------------------""",
> +                    version, download_base, delay, url
> +                ); from time import sleep; sleep(delay)
> +            log.warn("Downloading %s", url)
> +            src = urllib2.urlopen(url)
> +            # Read/write all in one block, so we don't create a corrupt file
> +            # if the download is interrupted.
> +            data = _validate_md5(egg_name, src.read())
> +            dst = open(saveto,"wb"); dst.write(data)
> +        finally:
> +            if src: src.close()
> +            if dst: dst.close()
> +    return os.path.realpath(saveto)
> +
> +def main(argv, version=DEFAULT_VERSION):
> +    """Install or upgrade setuptools and EasyInstall"""
> +
> +    try:
> +        import setuptools
> +    except ImportError:
> +        egg = None
> +        try:
> +            egg = download_setuptools(version, delay=0)
> +            sys.path.insert(0,egg)
> +            from setuptools.command.easy_install import main
> +            return main(list(argv)+[egg])   # we're done here
> +        finally:
> +            if egg and os.path.exists(egg):
> +                os.unlink(egg)
> +    else:
> +        if setuptools.__version__ == '0.0.1':
> +            # tell the user to uninstall obsolete version
> +            use_setuptools(version)
> +
> +    req = "setuptools>="+version
> +    import pkg_resources
> +    try:
> +        pkg_resources.require(req)
> +    except pkg_resources.VersionConflict:
> +        try:
> +            from setuptools.command.easy_install import main
> +        except ImportError:
> +            from easy_install import main
> +        main(list(argv)+[download_setuptools(delay=0)])
> +        sys.exit(0) # try to force an exit
> +    else:
> +        if argv:
> +            from setuptools.command.easy_install import main
> +            main(argv)
> +        else:
> +            print "Setuptools version",version,"or greater has been installed."
> +            print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
> +
> +
> +
> +def update_md5(filenames):
> +    """Update our built-in md5 registry"""
> +
> +    import re
> +    from md5 import md5
> +
> +    for name in filenames:
> +        base = os.path.basename(name)
> +        f = open(name,'rb')
> +        md5_data[base] = md5(f.read()).hexdigest()
> +        f.close()
> +
> +    data = ["    %r: %r,\n" % it for it in md5_data.items()]
> +    data.sort()
> +    repl = "".join(data)
> +
> +    import inspect
> +    srcfile = inspect.getsourcefile(sys.modules[__name__])
> +    f = open(srcfile, 'rb'); src = f.read(); f.close()
> +
> +    match = re.search("\nmd5_data = {\n([^}]+)}", src)
> +    if not match:
> +        print>>sys.stderr, "Internal error!"
> +        sys.exit(2)
> +
> +    src = src[:match.start(1)] + repl + src[match.end(1):]
> +    f = open(srcfile,'w')
> +    f.write(src)
> +    f.close()
> +
> +
> +if __name__=='__main__':
> +    if len(sys.argv)>2 and sys.argv[1]=='--md5update':
> +        update_md5(sys.argv[2:])
> +    else:
> +        main(sys.argv[1:])
> diff --git a/server/ovirtserver/__init__.py b/server/ovirtserver/__init__.py
> new file mode 100644
> index 0000000..1d14a09
> --- /dev/null
> +++ b/server/ovirtserver/__init__.py
> @@ -0,0 +1,18 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""The server package"""
> diff --git a/server/ovirtserver/config/__init__.py b/server/ovirtserver/config/__init__.py
> new file mode 100644
> index 0000000..90ca87c
> --- /dev/null
> +++ b/server/ovirtserver/config/__init__.py
> @@ -0,0 +1,16 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> diff --git a/server/ovirtserver/config/app_cfg.py b/server/ovirtserver/config/app_cfg.py
> new file mode 100644
> index 0000000..8882a6b
> --- /dev/null
> +++ b/server/ovirtserver/config/app_cfg.py
> @@ -0,0 +1,54 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""
> +Global configuration file for TG2-specific settings in server.
> +
> +This file complements development/deployment.ini.
> +
> +Please note that **all the argument values are strings**. If you want to
> +convert them into boolean, for example, you should use the
> +:func:`paste.deploy.converters.asbool` function, as in::
> +
> +    from paste.deploy.converters import asbool
> +    setting = asbool(global_conf.get('the_setting'))
> +
> +"""
> +
> +from tg.configuration import AppConfig
> +
> +import ovirtserver
> +from ovirtserver import model
> +from ovirtserver.lib import app_globals, helpers
> +
> +base_config = AppConfig()
> +base_config.renderers = []
> +
> +base_config.package = ovirtserver
> +
> +#Set the default renderer
> +base_config.default_renderer = 'genshi'
> +base_config.renderers.append('genshi')
> +# if you want raw speed and have installed chameleon.genshi
> +# you should try to use this renderer instead.
> +# warning: for the moment chameleon does not handle i18n translations
> +#base_config.renderers.append('chameleon_genshi')
> +
> +#Configure the base SQLALchemy Setup
> +base_config.use_sqlalchemy = True
> +base_config.model = ovirtserver.model
> +base_config.DBSession = ovirtserver.model.DBSession
> diff --git a/server/ovirtserver/config/deployment.ini_tmpl b/server/ovirtserver/config/deployment.ini_tmpl
> new file mode 100644
> index 0000000..7b1403c
> --- /dev/null
> +++ b/server/ovirtserver/config/deployment.ini_tmpl
> @@ -0,0 +1,104 @@
> +# Copyright (C) yyyy, your name.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +#
> +# server - TurboGears configuration
> +#
> +# The %(here)s variable will be replaced with the parent directory of this file
> +#
> +[DEFAULT]
> +# WARGING == If debug is not set to false, you'll get the interactive
> +# debugger on production, which is a huge security hole.
> +
> +debug = false
> +email_to = you at yourdomain.com
> +smtp_server = localhost
> +error_email_from = paste at localhost
> +
> +[server:main]
> +use = egg:Paste#http
> +host = 0.0.0.0
> +port = 8080
> +
> +[app:main]
> +use = egg:server
> +full_stack = true
> +cache_dir = %(here)s/data
> +beaker.session.key = ovirtserver
> +beaker.session.secret = ${app_instance_secret}
> +app_instance_uuid = ${app_instance_uuid}
> +
> +# If you'd like to fine-tune the individual locations of the cache data dirs
> +# for the Cache data, or the Session saves, un-comment the desired settings
> +# here:
> +#beaker.cache.data_dir = %(here)s/data/cache
> +#beaker.session.data_dir = %(here)s/data/sessions
> +# Specify the database for SQLAlchemy to use via
> +# turbogears.database
> +# %(here) may include a ':' character on Windows environments; this can
> +# invalidate the URI when specifying a SQLite db via path name
> +sqlalchemy.url = sqlite:///%(here)s/somedb.db
> +sqlalchemy.echo = False
> +
> +# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
> +# Debug mode will enable the interactive debugging tool, allowing ANYONE to
> +# execute malicious code after an exception is raised.
> +#set debug = false
> +
> +# Logging configuration
> +# Add additional loggers, handlers, formatters here
> +# Uses python's logging config file format
> +# http://docs.python.org/lib/logging-config-fileformat.html
> +
> +[loggers]
> +keys = root, ovirtserver, sqlalchemy
> +
> +[handlers]
> +keys = console
> +
> +[formatters]
> +keys = generic
> +
> +# If you create additional loggers, add them as a key to [loggers]
> +[logger_root]
> +level = INFO
> +handlers = console
> +
> +[logger_ovirtserver]
> +level = INFO
> +handlers =
> +qualname = ovirtserver
> +
> +[logger_sqlalchemy]
> +level = WARN
> +handlers =
> +qualname = sqlalchemy.engine
> +# "level = INFO" logs SQL queries.
> +# "level = DEBUG" logs SQL queries and results.
> +# "level = WARN" logs neither.  (Recommended for production systems.)
> +
> +
> +# If you create additional handlers, add them as a key to [handlers]
> +[handler_console]
> +class = StreamHandler
> +args = (sys.stderr,)
> +level = NOTSET
> +formatter = generic
> +
> +# If you create additional formatters, add them as a key to [formatters]
> +[formatter_generic]
> +format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
> +datefmt = %H:%M:%S
> diff --git a/server/ovirtserver/config/environment.py b/server/ovirtserver/config/environment.py
> new file mode 100644
> index 0000000..01b0275
> --- /dev/null
> +++ b/server/ovirtserver/config/environment.py
> @@ -0,0 +1,25 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""WSGI environment setup for server."""
> +
> +from ovirtserver.config.app_cfg import base_config
> +
> +__all__ = ['load_environment']
> +
> +#Use base_config to setup the environment loader function
> +load_environment = base_config.make_load_environment()
> diff --git a/server/ovirtserver/config/middleware.py b/server/ovirtserver/config/middleware.py
> new file mode 100644
> index 0000000..b5f47da
> --- /dev/null
> +++ b/server/ovirtserver/config/middleware.py
> @@ -0,0 +1,55 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""WSGI middleware initialization for the server application."""
> +
> +from ovirtserver.config.app_cfg import base_config
> +from ovirtserver.config.environment import load_environment
> +
> +
> +__all__ = ['make_app']
> +
> +# Use base_config to setup the necessary PasteDeploy application factory.
> +# make_base_app will wrap the TG2 app with all the middleware it needs.
> +make_base_app = base_config.setup_tg_wsgi_app(load_environment)
> +
> +
> +def make_app(global_conf, full_stack=True, **app_conf):
> +    """
> +    Set server up with the settings found in the PasteDeploy configuration
> +    file used.
> +
> +    :param global_conf: The global settings for server (those
> +        defined under the ``[DEFAULT]`` section).
> +    :type global_conf: dict
> +    :param full_stack: Should the whole TG2 stack be set up?
> +    :type full_stack: str or bool
> +    :return: The server application with all the relevant middleware
> +        loaded.
> +
> +    This is the PasteDeploy factory for the server application.
> +
> +    ``app_conf`` contains all the application-specific settings (those defined
> +    under ``[app:main]``.
> +
> +
> +    """
> +    app = make_base_app(global_conf, full_stack=True, **app_conf)
> +
> +    # Wrap your base TurboGears 2 application with custom middleware here
> +
> +    return app
> diff --git a/server/ovirtserver/controllers/__init__.py b/server/ovirtserver/controllers/__init__.py
> new file mode 100644
> index 0000000..417d5ed
> --- /dev/null
> +++ b/server/ovirtserver/controllers/__init__.py
> @@ -0,0 +1,18 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Controllers for the server application."""
> diff --git a/server/ovirtserver/controllers/controller.template b/server/ovirtserver/controllers/controller.template
> new file mode 100644
> index 0000000..2de6832
> --- /dev/null
> +++ b/server/ovirtserver/controllers/controller.template
> @@ -0,0 +1,36 @@
> +# Copyright (C) yyyy, your name
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Sample controller module"""
> +
> +# turbogears imports
> +from tg import expose
> +#from tg import redirect, validate, flash
> +
> +# third party imports
> +#from pylons.i18n import ugettext as _
> +#from repoze.what import predicates
> +
> +# project specific imports
> +from ovirtserver.lib.base import BaseController
> +#from ovirtserver.model import DBSession, metadata
> +
> +
> +class SampleController(BaseController):
> +
> +    @expose('ovirtserver.templates.index')
> +    def index(self):
> +        return dict(page='index')
> diff --git a/server/ovirtserver/controllers/error.py b/server/ovirtserver/controllers/error.py
> new file mode 100644
> index 0000000..6a14218
> --- /dev/null
> +++ b/server/ovirtserver/controllers/error.py
> @@ -0,0 +1,46 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Error controller"""
> +
> +from tg import request, expose
> +
> +__all__ = ['ErrorController']
> +
> +
> +class ErrorController(object):
> +    """
> +    Generates error documents as and when they are required.
> +
> +    The ErrorDocuments middleware forwards to ErrorController when error
> +    related status codes are returned from the application.
> +
> +    This behaviour can be altered by changing the parameters to the
> +    ErrorDocuments middleware in your config/middleware.py file.
> +
> +    """
> +
> +    @expose('ovirtserver.templates.error')
> +    def document(self, *args, **kwargs):
> +        """Render the error document"""
> +        resp = request.environ.get('pylons.original_response')
> +        default_message = ("<p>We're sorry but we weren't able to process "
> +                           " this request.</p>")
> +        values = dict(prefix=request.environ.get('SCRIPT_NAME', ''),
> +                      code=request.params.get('code', resp.status_int),
> +                      message=request.params.get('message', default_message))
> +        return values
> diff --git a/server/ovirtserver/controllers/root.py b/server/ovirtserver/controllers/root.py
> new file mode 100644
> index 0000000..cfd682b
> --- /dev/null
> +++ b/server/ovirtserver/controllers/root.py
> @@ -0,0 +1,55 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Main Controller"""
> +
> +from tg import expose, flash, require, url, request, redirect
> +from pylons.i18n import ugettext as _, lazy_ugettext as l_
> +
> +from ovirtserver.lib.base import BaseController
> +from ovirtserver.model import DBSession, metadata
> +from ovirtserver.controllers.error import ErrorController
> +
> +__all__ = ['RootController']
> +
> +
> +class RootController(BaseController):
> +    """
> +    The root controller for the server application.
> +
> +    All the other controllers and WSGI applications should be mounted on this
> +    controller. For example::
> +
> +        panel = ControlPanelController()
> +        another_app = AnotherWSGIApplication()
> +
> +    Keep in mind that WSGI applications shouldn't be mounted directly: They
> +    must be wrapped around with :class:`tg.controllers.WSGIAppController`.
> +
> +    """
> +
> +    error = ErrorController()
> +
> +    @expose('ovirtserver.templates.index')
> +    def index(self):
> +        """Handle the front-page."""
> +        return dict(page='index')
> +
> +    @expose('ovirtserver.templates.about')
> +    def about(self):
> +        """Handle the 'about' page."""
> +        return dict(page='about')
> diff --git a/server/ovirtserver/controllers/secure.py b/server/ovirtserver/controllers/secure.py
> new file mode 100644
> index 0000000..adb98f7
> --- /dev/null
> +++ b/server/ovirtserver/controllers/secure.py
> @@ -0,0 +1,21 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Sample controller with all its actions protected."""
> +
> +# This controller is only used when you activate auth. You can safely remove
> +# this file from your project.
> diff --git a/server/ovirtserver/controllers/template.py b/server/ovirtserver/controllers/template.py
> new file mode 100644
> index 0000000..77a1fcb
> --- /dev/null
> +++ b/server/ovirtserver/controllers/template.py
> @@ -0,0 +1,51 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Fallback controller."""
> +
> +from ovirtserver.lib.base import BaseController
> +
> +__all__ = ['TemplateController']
> +
> +
> +class TemplateController(BaseController):
> +    """
> +    The fallback controller for server.
> +
> +    By default, the final controller tried to fulfill the request
> +    when no other routes match. It may be used to display a template
> +    when all else fails, e.g.::
> +
> +        def view(self, url):
> +            return render('/%s' % url)
> +
> +    Or if you're using Mako and want to explicitly send a 404 (Not
> +    Found) response code when the requested template doesn't exist::
> +
> +        import mako.exceptions
> +
> +        def view(self, url):
> +            try:
> +                return render('/%s' % url)
> +            except mako.exceptions.TopLevelLookupException:
> +                abort(404)
> +
> +    """
> +
> +    def view(self, url):
> +        """Abort the request with a 404 HTTP status code."""
> +        abort(404)
> diff --git a/server/ovirtserver/i18n/ru/LC_MESSAGES/ovirtserver.po b/server/ovirtserver/i18n/ru/LC_MESSAGES/ovirtserver.po
> new file mode 100644
> index 0000000..36532d4
> --- /dev/null
> +++ b/server/ovirtserver/i18n/ru/LC_MESSAGES/ovirtserver.po
> @@ -0,0 +1,24 @@
> +# Russian translations for ${package}.
> +# Copyright (C) 2008 ORGANIZATION
> +# This file is distributed under the same license as the ${package} project.
> +# FIRST AUTHOR<EMAIL at ADDRESS>, 2008.
> +#
> +msgid ""
> +msgstr ""
> +"Project-Id-Version: ${package} 0.0.0\n"
> +"Report-Msgid-Bugs-To: EMAIL at ADDRESS\n"
> +"POT-Creation-Date: 2008-01-13 14:00+0200\n"
> +"PO-Revision-Date: 2008-01-13 14:00+0200\n"
> +"Last-Translator: FULL NAME<EMAIL at ADDRESS>\n"
> +"Language-Team: ru<LL at li.org>\n"
> +"Plural-Forms: nplurals=3; plural=(n%10==1&&  n%100!=11 ? 0 : n%10>=2&&  "
> +"n%10<=4&&  (n%100<10 || n%100>=20) ? 1 : 2)\n"
> +"MIME-Version: 1.0\n"
> +"Content-Type: text/plain; charset=utf-8\n"
> +"Content-Transfer-Encoding: 8bit\n"
> +"Generated-By: Babel 0.9.1\n"
> +
> +#: ${package}/controllers/root.py:13
> +msgid "Your application is now running"
> +msgstr "Ваши приложение успешно запущено"
> +
> diff --git a/server/ovirtserver/lib/__init__.py b/server/ovirtserver/lib/__init__.py
> new file mode 100644
> index 0000000..90ca87c
> --- /dev/null
> +++ b/server/ovirtserver/lib/__init__.py
> @@ -0,0 +1,16 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> diff --git a/server/ovirtserver/lib/app_globals.py b/server/ovirtserver/lib/app_globals.py
> new file mode 100644
> index 0000000..d5d2abe
> --- /dev/null
> +++ b/server/ovirtserver/lib/app_globals.py
> @@ -0,0 +1,33 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""The application's Globals object"""
> +
> +__all__ = ['Globals']
> +
> +
> +class Globals(object):
> +    """Container for objects available throughout the life of the application.
> +
> +    One instance of Globals is created during application initialization and
> +    is available during requests via the 'app_globals' variable.
> +
> +    """
> +
> +    def __init__(self):
> +        """Do nothing, by default."""
> +        pass
> diff --git a/server/ovirtserver/lib/base.py b/server/ovirtserver/lib/base.py
> new file mode 100644
> index 0000000..90772cc
> --- /dev/null
> +++ b/server/ovirtserver/lib/base.py
> @@ -0,0 +1,44 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""The base Controller API."""
> +
> +from tg import TGController, tmpl_context
> +from tg.render import render
> +from pylons.i18n import _, ungettext, N_
> +from tw.api import WidgetBunch
> +import ovirtserver.model as model
> +
> +__all__ = ['Controller', 'BaseController']
> +
> +
> +class BaseController(TGController):
> +    """
> +    Base class for the controllers in the application.
> +
> +    Your web application should have one of these. The root of
> +    your application is used to compute URLs used by your app.
> +
> +    """
> +
> +    def __call__(self, environ, start_response):
> +        """Invoke the Controller"""
> +        # TGController.__call__ dispatches to the Controller method
> +        # the request is routed to. This routing information is
> +        # available in environ['pylons.routes_dict']
> +
> +        return TGController.__call__(self, environ, start_response)
> diff --git a/server/ovirtserver/lib/helpers.py b/server/ovirtserver/lib/helpers.py
> new file mode 100644
> index 0000000..88cdc0f
> --- /dev/null
> +++ b/server/ovirtserver/lib/helpers.py
> @@ -0,0 +1,20 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""WebHelpers used in server."""
> +
> +from webhelpers import date, feedgenerator, html, number, misc, text
> diff --git a/server/ovirtserver/model/__init__.py b/server/ovirtserver/model/__init__.py
> new file mode 100644
> index 0000000..1b37524
> --- /dev/null
> +++ b/server/ovirtserver/model/__init__.py
> @@ -0,0 +1,77 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""The application's model objects"""
> +
> +from zope.sqlalchemy import ZopeTransactionExtension
> +from sqlalchemy.orm import scoped_session, sessionmaker
> +#from sqlalchemy import MetaData
> +from sqlalchemy.ext.declarative import declarative_base
> +
> +# Global session manager: DBSession() returns the Thread-local
> +# session object appropriate for the current web request.
> +maker = sessionmaker(autoflush=True, autocommit=False,
> +                     extension=ZopeTransactionExtension())
> +DBSession = scoped_session(maker)
> +
> +# Base class for all of our model classes: By default, the data model is
> +# defined with SQLAlchemy's declarative extension, but if you need more
> +# control, you can switch to the traditional method.
> +DeclarativeBase = declarative_base()
> +
> +# There are two convenient ways for you to spare some typing.
> +# You can have a query property on all your model classes by doing this:
> +# DeclarativeBase.query = DBSession.query_property()
> +# Or you can use a session-aware mapper as it was used in TurboGears 1:
> +# DeclarativeBase = declarative_base(mapper=DBSession.mapper)
> +
> +# Global metadata.
> +# The default metadata is the one from the declarative base.
> +metadata = DeclarativeBase.metadata
> +
> +# If you have multiple databases with overlapping table names, you'll need a
> +# metadata for each database. Feel free to rename 'metadata2'.
> +#metadata2 = MetaData()
> +
> +#####
> +# Generally you will not want to define your table's mappers, and data objects
> +# here in __init__ but will want to create modules them in the model directory
> +# and import them at the bottom of this file.
> +#
> +######
> +
> +def init_model(engine):
> +    """Call me before using any of the tables or classes in the model."""
> +
> +    DBSession.configure(bind=engine)
> +    # If you are using reflection to introspect your database and create
> +    # table objects for you, your tables must be defined and mapped inside
> +    # the init_model function, so that the engine is available if you
> +    # use the model outside tg2, you need to make sure this is called before
> +    # you use the model.
> +
> +    #
> +    # See the following example:
> +
> +    #global t_reflected
> +
> +    #t_reflected = Table("Reflected", metadata,
> +    #    autoload=True, autoload_with=engine)
> +
> +    #mapper(Reflected, t_reflected)
> +
> +# Import your model modules here.
> diff --git a/server/ovirtserver/model/auth.py b/server/ovirtserver/model/auth.py
> new file mode 100644
> index 0000000..d7ea74b
> --- /dev/null
> +++ b/server/ovirtserver/model/auth.py
> @@ -0,0 +1,27 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""
> +Auth* related model.
> +
> +This is where the models used by :mod:`repoze.who` and :mod:`repoze.what` are
> +defined.
> +
> +It's perfectly fine to re-use this definition in the server application,
> +though.
> +
> +"""
> diff --git a/server/ovirtserver/model/model.template b/server/ovirtserver/model/model.template
> new file mode 100644
> index 0000000..716807e
> --- /dev/null
> +++ b/server/ovirtserver/model/model.template
> @@ -0,0 +1,37 @@
> +# Copyright (C) yyyy, your name.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Sample model module."""
> +
> +from sqlalchemy import *
> +from sqlalchemy.orm import mapper, relation
> +from sqlalchemy import Table, ForeignKey, Column
> +from sqlalchemy.types import Integer, Unicode
> +#from sqlalchemy.orm import relation, backref
> +
> +from ovirtserver.model import DeclarativeBase, metadata, DBSession
> +
> +
> +class SampleModel(DeclarativeBase):
> +    __tablename__ = 'sample_model'
> +
> +    #{ Columns
> +
> +    id = Column(Integer, primary_key=True)
> +
> +    data = Column(Unicode(255), nullable=False)
> +
> +    #}
> diff --git a/server/ovirtserver/public/favicon.ico b/server/ovirtserver/public/favicon.ico
> new file mode 100644
> index 0000000000000000000000000000000000000000..840986e4705befe9beb4275e2807fd358a362497
> GIT binary patch
> literal 1104
> zcmV-W1h4xaiwFP!000000|7Y%#`{M}MmRZP5C9MW=S=`zU0s?(6{e=9adB~piHWPL
> ztMKsf<mBXhe0;dLxYLng)6>)U_xHB8w!DmPpP!#EEiT>N-OZzotgNilw50s}{OQ-t
> z^78VNlas>2!U6&U#KgqR%*?*NzOJsW&d$!SbyBdfu%Muz$;rva#>TX?w3(Ti+uPgs
> z&04auvZ$!2y1Kf(y}gex2j}PK(9qCSktL<vVARyqhlhvUZDREF^lmT{>!dMnZf at o5
> z^=WBo?eqTG!L-)a*6Ql&*x1;RX;!tCefaqJQBhIy=HN$1M}|Wt-{0TEn}yfO!GVE+
> zq*N-`-RJ-R|LpASW at ct!U|@4WF3Wo@$oPbyO(IuUSF(ar`tX0OW<jP}GRDi*+u-Zs
> z>F<|!XSIN1g<D9uzQ^z4+w=PUzN3)M(%kl<k=f77aIGXhY%!Q at I`xi%a8OC)&A_Ir
> zviJS}+||(e^zxp*oN8=wl81+Zu}tCS?f9;wnx3WY at bUQZ?!Lp!o}#J1u%hAQ=CZcG
> z>F at gA;^d5tjqK&(Vr6Ob_W0=R?)?A%)7RUD!9CjD-;a-v=<Do_kc4h=c6WM!`}g(E
> z#J<3<Nd5cz at bvbpueWt|cA=%Mj**z|_4(Y`)q;hK`1}3l-`vvJ;!I6VQ&m~EsiWE3
> z-FkyVq=s}IHWu^q^ITtJ{rvj-`uXtl_TAs$6B878czF8w_~-BQg^7>j<Kyx1@$K#H
> zPEb=_U}Up0E^mi!IyyR%mYwzO>A}IlqoboyQ&+&&w#&=Qrjm-vP)P6Z at 9ysI`}_OK
> z%F4jN!2bUJ`uh6f;^M)^&t_<C{{R2~{{HLn{6RuO{{H{@`T70*{rda+_VxAq{r>Rs
> z^3l at O)Y8(|)Y8MYtj4>w=-kzvNgU77)ZyXb;o{@<_4W4l_V at Pn&CShIQ&aBl?dj?1
> z>+9>x$HQV{Wy{OVfpc@~>*{A`XINNRT3TDkzqtPX{d|9grlg}C92_JgBg at duy1Tij
> zr=`o!%<J#*;^XA%>gmD1y~4r3mYSg<{uM)VWnpw>WFU8GbZ8({Xk{QrNlj1yEC2ui
> z01yBW000R70Gl*n*5r*DAr*v}c{5O;!(~W<1i at wwn?xk>911*^&58pDNEBGHl1-Y!
> zV+_iHa4-fQI!I$2baBGqn6V%Zf~2u`ViBH2C-SAi8N`^CG-*<Jd$FXc8E at IrSdl`l
> z&{0)KTF_7<rNt3dQe6oF*X0W!bS<PP=nARNmo7D;QH!#s4>}uEuuy4%&c&K2(ToAH
> z@#V*fF*a<p7;_ at R7aKsD7>N?4%eiatvSoO&s7n+hMhu}Fm8LSRK7Cxk>S9DHBxp6v
> z^#Ky)%NHQGqX60GqJ}YJ6~YCHVxu;3Bfr8`Fy^oVBqLu=oJjP=2&4)cn?$>?=$ot>
> WvS0=+x)9A_Kma>NIMN(B1ONa82$stL
>
> literal 0
> HcmV?d00001
>
> diff --git a/server/ovirtserver/templates/__init__.py b/server/ovirtserver/templates/__init__.py
> new file mode 100644
> index 0000000..14d408b
> --- /dev/null
> +++ b/server/ovirtserver/templates/__init__.py
> @@ -0,0 +1,18 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Templates package for the application."""
> diff --git a/server/ovirtserver/templates/error.html b/server/ovirtserver/templates/error.html
> new file mode 100644
> index 0000000..001f8f4
> --- /dev/null
> +++ b/server/ovirtserver/templates/error.html
> @@ -0,0 +1,19 @@
> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> +                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> +<html xmlns="http://www.w3.org/1999/xhtml"
> +      xmlns:py="http://genshi.edgewall.org/"
> +      xmlns:xi="http://www.w3.org/2001/XInclude">
> +
> +<xi:include href="master.html" />
> +
> +<head>
> +<meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
> +<title>A ${code} Error has Occurred</title>
> +</head>
> +
> +<body>
> +<h1>Error ${code}</h1>
> +
> +<div>${XML(message)}</div>
> +</body>
> +</html>
> diff --git a/server/ovirtserver/templates/index.html b/server/ovirtserver/templates/index.html
> new file mode 100644
> index 0000000..1c2496b
> --- /dev/null
> +++ b/server/ovirtserver/templates/index.html
> @@ -0,0 +1,20 @@
> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> +          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> +<html xmlns="http://www.w3.org/1999/xhtml"
> +      xmlns:py="http://genshi.edgewall.org/"
> +      xmlns:xi="http://www.w3.org/2001/XInclude">
> +
> +<head>
> +<meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
> +<title>Welcome to the oVirt management server</title>
> +</head>
> +
> +<body>
> +<h1>Welcome To The oVirt Server Reference Implementation</h1>
> +
> +<p>
> +      This server provides a reference implementation for how a management server should interact
> +      with the oVirt managed node.
> +</p>
> +</body>
> +</html>
> diff --git a/server/ovirtserver/tests/__init__.py b/server/ovirtserver/tests/__init__.py
> new file mode 100644
> index 0000000..7c1a4a9
> --- /dev/null
> +++ b/server/ovirtserver/tests/__init__.py
> @@ -0,0 +1,80 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Unit and functional test suite for server."""
> +
> +from os import path
> +import sys
> +
> +from tg import config
> +from paste.deploy import loadapp
> +from paste.script.appinstall import SetupCommand
> +from routes import url_for
> +from webtest import TestApp
> +from nose.tools import eq_
> +
> +from ovirtserver import model
> +
> +__all__ = ['setup_db', 'teardown_db', 'TestController', 'url_for']
> +
> +def setup_db():
> +    """Method used to build a database"""
> +    engine = config['pylons.app_globals'].sa_engine
> +    model.init_model(engine)
> +    model.metadata.create_all(engine)
> +
> +def teardown_db():
> +    """Method used to destroy a database"""
> +    engine = config['pylons.app_globals'].sa_engine
> +    model.metadata.drop_all(engine)
> +
> +
> +class TestController(object):
> +    """
> +    Base functional test case for the controllers.
> +
> +    The server application instance (``self.app``) set up in this test
> +    case (and descendants) has authentication disabled, so that developers can
> +    test the protected areas independently of the :mod:`repoze.who` plugins
> +    used initially. This way, authentication can be tested once and separately.
> +
> +    Check ovirtserver.tests.functional.test_authentication for the repoze.who
> +    integration tests.
> +
> +    This is the officially supported way to test protected areas with
> +    repoze.who-testutil (http://code.gustavonarea.net/repoze.who-testutil/).
> +
> +    """
> +
> +    application_under_test = 'main_without_authn'
> +
> +    def setUp(self):
> +        """Method called by nose before running each test"""
> +        # Loading the application:
> +        conf_dir = config.here
> +        wsgiapp = loadapp('config:test.ini#%s' % self.application_under_test,
> +                          relative_to=conf_dir)
> +        self.app = TestApp(wsgiapp)
> +        # Setting it up:
> +        test_file = path.join(conf_dir, 'test.ini')
> +        cmd = SetupCommand('setup-app')
> +        cmd.run([test_file])
> +
> +    def tearDown(self):
> +        """Method called by nose after running each test"""
> +        # Cleaning up the database:
> +        teardown_db()
> diff --git a/server/ovirtserver/tests/functional/__init__.py b/server/ovirtserver/tests/functional/__init__.py
> new file mode 100644
> index 0000000..be0e5fb
> --- /dev/null
> +++ b/server/ovirtserver/tests/functional/__init__.py
> @@ -0,0 +1,18 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Functional test suite for the controllers of the application."""
> diff --git a/server/ovirtserver/tests/functional/test_authentication.py b/server/ovirtserver/tests/functional/test_authentication.py
> new file mode 100644
> index 0000000..90ca87c
> --- /dev/null
> +++ b/server/ovirtserver/tests/functional/test_authentication.py
> @@ -0,0 +1,16 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> diff --git a/server/ovirtserver/tests/functional/test_root.py b/server/ovirtserver/tests/functional/test_root.py
> new file mode 100644
> index 0000000..5a7a55e
> --- /dev/null
> +++ b/server/ovirtserver/tests/functional/test_root.py
> @@ -0,0 +1,48 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""
> +Functional test suite for the root controller.
> +
> +This is an example of how functional tests can be written for controllers.
> +
> +As opposed to a unit-test, which test a small unit of functionality,
> +functional tests exercise the whole application and its WSGI stack.
> +
> +Please read http://pythonpaste.org/webtest/ for more information.
> +
> +"""
> +from nose.tools import assert_true
> +
> +from ovirtserver.tests import TestController
> +
> +
> +class TestRootController(TestController):
> +    def test_index(self):
> +        response = self.app.get('/')
> +        msg = 'TurboGears 2 is rapid web application development toolkit '\
> +              'designed to make your life easier.'
> +        # You can look for specific strings:
> +        assert_true(msg in response)
> +
> +        # You can also access a BeautifulSoup'ed response in your tests
> +        # (First run $ easy_install BeautifulSoup
> +        # and then uncomment the next two lines)
> +
> +        #links = response.html.findAll('a')
> +        #print links
> +        #assert_true(links, "Mummy, there are no links here!")
> diff --git a/server/ovirtserver/tests/models/__init__.py b/server/ovirtserver/tests/models/__init__.py
> new file mode 100644
> index 0000000..354b222
> --- /dev/null
> +++ b/server/ovirtserver/tests/models/__init__.py
> @@ -0,0 +1,68 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Unit test suite for the models of the application."""
> +from nose.tools import assert_equals
> +
> +from ovirtserver.model import DBSession
> +from ovirtserver.tests import setup_db, teardown_db
> +
> +__all__ = ['ModelTest']
> +
> +#Create an empty database before we start our tests for this module
> +def setup():
> +    """Function called by nose on module load"""
> +    setup_db()
> +
> +#Teardown that database
> +def teardown():
> +    """Function called by nose after all tests in this module ran"""
> +    teardown_db()
> +
> +class ModelTest(object):
> +    """Base unit test case for the models."""
> +
> +    klass = None
> +    attrs = {}
> +
> +    def setup(self):
> +        try:
> +            new_attrs = {}
> +            new_attrs.update(self.attrs)
> +            new_attrs.update(self.do_get_dependencies())
> +            self.obj = self.klass(**new_attrs)
> +            DBSession.add(self.obj)
> +            DBSession.flush()
> +            return self.obj
> +        except:
> +            DBSession.rollback()
> +            raise
> +
> +    def tearDown(self):
> +        DBSession.rollback()
> +
> +    def do_get_dependencies(self):
> +        """Use this method to pull in other objects that need to be created for this object to be build properly"""
> +        return {}
> +
> +    def test_create_obj(self):
> +        pass
> +
> +    def test_query_obj(self):
> +        obj = DBSession.query(self.klass).one()
> +        for key, value in self.attrs.iteritems():
> +            assert_equals(getattr(obj, key), value)
> diff --git a/server/ovirtserver/tests/models/test_auth.py b/server/ovirtserver/tests/models/test_auth.py
> new file mode 100644
> index 0000000..eb0fce0
> --- /dev/null
> +++ b/server/ovirtserver/tests/models/test_auth.py
> @@ -0,0 +1,22 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Test suite for the TG app's models"""
> +from nose.tools import eq_
> +
> +from ovirtserver import model
> +from ovirtserver.tests.models import ModelTest
> diff --git a/server/ovirtserver/websetup.py b/server/ovirtserver/websetup.py
> new file mode 100644
> index 0000000..36e3d8c
> --- /dev/null
> +++ b/server/ovirtserver/websetup.py
> @@ -0,0 +1,42 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +"""Setup the server application"""
> +
> +import logging
> +
> +import transaction
> +from tg import config
> +
> +from ovirtserver.config.environment import load_environment
> +
> +__all__ = ['setup_app']
> +
> +log = logging.getLogger(__name__)
> +
> +
> +def setup_app(command, conf, vars):
> +    """Place any commands to setup ovirtserver here"""
> +    load_environment(conf.global_conf, conf.local_conf)
> +    # Load the models
> +    from ovirtserver import model
> +    print "Creating tables"
> +    model.metadata.create_all(bind=config['pylons.app_globals'].sa_engine)
> +
> +
> +    transaction.commit()
> +    print "Successfully setup"
> diff --git a/server/server.egg-info/PKG-INFO b/server/server.egg-info/PKG-INFO
> new file mode 100644
> index 0000000..2ad8b9b
> --- /dev/null
> +++ b/server/server.egg-info/PKG-INFO
> @@ -0,0 +1,10 @@
> +Metadata-Version: 1.0
> +Name: server
> +Version: 0.1dev
> +Summary: UNKNOWN
> +Home-page: UNKNOWN
> +Author: UNKNOWN
> +Author-email: UNKNOWN
> +License: UNKNOWN
> +Description: UNKNOWN
> +Platform: UNKNOWN
> diff --git a/server/server.egg-info/SOURCES.txt b/server/server.egg-info/SOURCES.txt
> new file mode 100644
> index 0000000..4632e06
> --- /dev/null
> +++ b/server/server.egg-info/SOURCES.txt
> @@ -0,0 +1,68 @@
> +MANIFEST.in
> +README.txt
> +setup.cfg
> +setup.py
> +ovirtserver/__init__.py
> +ovirtserver/websetup.py
> +ovirtserver/config/__init__.py
> +ovirtserver/config/app_cfg.py
> +ovirtserver/config/environment.py
> +ovirtserver/config/middleware.py
> +ovirtserver/controllers/__init__.py
> +ovirtserver/controllers/error.py
> +ovirtserver/controllers/root.py
> +ovirtserver/controllers/secure.py
> +ovirtserver/controllers/template.py
> +ovirtserver/i18n/ru/LC_MESSAGES/ovirtserver.po
> +ovirtserver/lib/__init__.py
> +ovirtserver/lib/app_globals.py
> +ovirtserver/lib/base.py
> +ovirtserver/lib/helpers.py
> +ovirtserver/model/__init__.py
> +ovirtserver/model/auth.py
> +ovirtserver/public/favicon.ico
> +ovirtserver/public/css/style.css
> +ovirtserver/public/images/contentbg.png
> +ovirtserver/public/images/error.png
> +ovirtserver/public/images/header_inner2.png
> +ovirtserver/public/images/headerbg.png
> +ovirtserver/public/images/info.png
> +ovirtserver/public/images/inputbg.png
> +ovirtserver/public/images/loginbg.png
> +ovirtserver/public/images/loginbottombg.png
> +ovirtserver/public/images/loginheader-left.png
> +ovirtserver/public/images/loginheader-right.png
> +ovirtserver/public/images/menu-item-actibg-first.png
> +ovirtserver/public/images/menu-item-actibg.png
> +ovirtserver/public/images/menu-item-border.png
> +ovirtserver/public/images/menubg.png
> +ovirtserver/public/images/ok.png
> +ovirtserver/public/images/pagebg.png
> +ovirtserver/public/images/star.png
> +ovirtserver/public/images/strype2.png
> +ovirtserver/public/images/under_the_hood_blue.png
> +ovirtserver/public/images/warning.png
> +ovirtserver/templates/__init__.py
> +ovirtserver/templates/about.html
> +ovirtserver/templates/authentication.html
> +ovirtserver/templates/debug.html
> +ovirtserver/templates/error.html
> +ovirtserver/templates/footer.html
> +ovirtserver/templates/header.html
> +ovirtserver/templates/index.html
> +ovirtserver/templates/login.html
> +ovirtserver/templates/master.html
> +ovirtserver/templates/sidebars.html
> +ovirtserver/tests/__init__.py
> +ovirtserver/tests/functional/__init__.py
> +ovirtserver/tests/functional/test_authentication.py
> +ovirtserver/tests/functional/test_root.py
> +ovirtserver/tests/models/__init__.py
> +ovirtserver/tests/models/test_auth.py
> +server.egg-info/PKG-INFO
> +server.egg-info/SOURCES.txt
> +server.egg-info/dependency_links.txt
> +server.egg-info/entry_points.txt
> +server.egg-info/paster_plugins.txt
> +server.egg-info/requires.txt
> +server.egg-info/top_level.txt
> \ No newline at end of file
> diff --git a/server/server.egg-info/dependency_links.txt b/server/server.egg-info/dependency_links.txt
> new file mode 100644
> index 0000000..8b13789
> --- /dev/null
> +++ b/server/server.egg-info/dependency_links.txt
> @@ -0,0 +1 @@
> +
> diff --git a/server/server.egg-info/entry_points.txt b/server/server.egg-info/entry_points.txt
> new file mode 100644
> index 0000000..da62946
> --- /dev/null
> +++ b/server/server.egg-info/entry_points.txt
> @@ -0,0 +1,7 @@
> +
> +    [paste.app_factory]
> +    main = ovirtserver.config.middleware:make_app
> +
> +    [paste.app_install]
> +    main = pylons.util:PylonsInstaller
> +
> \ No newline at end of file
> diff --git a/server/server.egg-info/paster_plugins.txt b/server/server.egg-info/paster_plugins.txt
> new file mode 100644
> index 0000000..ab508e5
> --- /dev/null
> +++ b/server/server.egg-info/paster_plugins.txt
> @@ -0,0 +1,4 @@
> +PasteScript
> +Pylons
> +TurboGears2
> +tg.devtools
> diff --git a/server/server.egg-info/requires.txt b/server/server.egg-info/requires.txt
> new file mode 100644
> index 0000000..661a57b
> --- /dev/null
> +++ b/server/server.egg-info/requires.txt
> @@ -0,0 +1,6 @@
> +TurboGears2>= 2.0b7
> +Catwalk>= 2.0.2
> +Babel>=0.9.4
> +toscawidgets>= 0.9.7.1
> +zope.sqlalchemy>= 0.4
> +repoze.tm2>= 1.0a4
> \ No newline at end of file
> diff --git a/server/server.egg-info/top_level.txt b/server/server.egg-info/top_level.txt
> new file mode 100644
> index 0000000..4e4dbeb
> --- /dev/null
> +++ b/server/server.egg-info/top_level.txt
> @@ -0,0 +1 @@
> +ovirtserver
> diff --git a/server/setup.cfg b/server/setup.cfg
> new file mode 100644
> index 0000000..cb01cf9
> --- /dev/null
> +++ b/server/setup.cfg
> @@ -0,0 +1,32 @@
> +[egg_info]
> +tag_build = dev
> +tag_svn_revision = true
> +
> +[easy_install]
> +find_links = http://www.pylonshq.com/download/
> +
> +[nosetests]
> +with-pylons=test.ini
> +
> +# Babel configuration
> +[compile_catalog]
> +domain = ovirtserver
> +directory = ovirtserver/i18n
> +statistics = true
> +
> +[extract_messages]
> +add_comments = TRANSLATORS:
> +output_file = ovirtserver/i18n/ovirtserver.pot
> +width = 80
> +keywords = l_
> +
> +[init_catalog]
> +domain = ovirtserver
> +input_file = ovirtserver/i18n/ovirtserver.pot
> +output_dir = ovirtserver/i18n
> +
> +[update_catalog]
> +domain = ovirtserver
> +input_file = ovirtserver/i18n/ovirtserver.pot
> +output_dir = ovirtserver/i18n
> +previous = true
> diff --git a/server/setup.py b/server/setup.py
> new file mode 100644
> index 0000000..bf646ad
> --- /dev/null
> +++ b/server/setup.py
> @@ -0,0 +1,63 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +try:
> +    from setuptools import setup, find_packages
> +except ImportError:
> +    from ez_setup import use_setuptools
> +    use_setuptools()
> +    from setuptools import setup, find_packages
> +
> +setup(
> +    name='server',
> +    version='0.1',
> +    description='',
> +    author='',
> +    author_email='',
> +    #url='',
> +    install_requires=[
> +        "TurboGears2>= 2.0b7",
> +        "Catwalk>= 2.0.2",
> +        "Babel>=0.9.4",
> +        #can be removed iif use_toscawidgets = False
> +        "toscawidgets>= 0.9.7.1",
> +        "zope.sqlalchemy>= 0.4 ",
> +        "repoze.tm2>= 1.0a4",
> +                        ],
> +    setup_requires=["PasteScript>= 1.7"],
> +    paster_plugins=['PasteScript', 'Pylons', 'TurboGears2', 'tg.devtools'],
> +    packages=find_packages(exclude=['ez_setup']),
> +    include_package_data=True,
> +    test_suite='nose.collector',
> +    tests_require=['WebTest', 'BeautifulSoup'],
> +    package_data={'ovirtserver': ['i18n/*/LC_MESSAGES/*.mo',
> +                                 'templates/*/*',
> +                                 'public/*/*']},
> +    message_extractors={'ovirtserver': [
> +            ('**.py', 'python', None),
> +            ('templates/**.mako', 'mako', None),
> +            ('templates/**.html', 'genshi', None),
> +            ('public/**', 'ignore', None)]},
> +
> +    entry_points="""
> +    [paste.app_factory]
> +    main = ovirtserver.config.middleware:make_app
> +
> +    [paste.app_install]
> +    main = pylons.util:PylonsInstaller
> +    """,
> +)
> diff --git a/server/test.ini b/server/test.ini
> new file mode 100644
> index 0000000..415fcb0
> --- /dev/null
> +++ b/server/test.ini
> @@ -0,0 +1,42 @@
> +# Copyright (C) 2010, Red Hat, Inc.
> +# Written by Darryl L. Pierce
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License
> +# as published by the Free Software Foundation; either version 2
> +# of the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> +
> +#
> +# server - TurboGears 2 testing environment configuration
> +#
> +# The %(here)s variable will be replaced with the parent directory of this file
> +#
> +[DEFAULT]
> +debug = true
> +# Uncomment and replace with the address which should receive any error reports
> +# email_to = you at yourdomain.com
> +smtp_server = localhost
> +error_email_from = paste at localhost
> +
> +[server:main]
> +use = egg:Paste#http
> +host = 0.0.0.0
> +port = 5000
> +
> +[app:main]
> +use = config:development.ini
> +
> +[app:main_without_authn]
> +use = main
> +skip_authentication = True
> +
> +# Add additional test specific configuration options as necessary.
>
>
>
> _______________________________________________
> Ovirt-devel mailing list
> Ovirt-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/ovirt-devel




More information about the ovirt-devel mailing list