Commits

paul.paj  committed f1479ea

[svn] Add demo application

  • Participants
  • Parent commits 253f5f5

Comments (0)

Files changed (51)

File dyndemo/README.txt

+dyndemo
+
+This is a TurboGears (http://www.turbogears.org) project. It can be
+started by running the start-dyndemo.py script.

File dyndemo/dev.cfg

+[global]
+# This is where all of your settings go for your development environment
+# Settings that are the same for both development and production
+# (such as template engine, encodings, etc.) all go in
+# dyndemo/config/app.cfg
+
+# DATABASE
+
+# driver://username:password@host:port/database
+
+# pick the form for your database
+# sqlalchemy.dburi="postgres://username@hostname/databasename"
+# sqlalchemy.dburi="mysql://username:password@hostname:port/databasename"
+# sqlalchemy.dburi="sqlite://%(current_dir_uri)s/devdata.sqlite"
+
+# If you have sqlite, here's a simple default to get you started
+# in development
+sqlalchemy.dburi="sqlite:///devdata.sqlite"
+
+
+# SERVER
+
+# Some server parameters that you may want to tweak
+server.socket_port=8080
+toscawidgets.on = True
+
+# Enable the debug output at the end on pages.
+# log_debug_info_filter.on = False
+
+server.environment="development"
+autoreload.package="dyndemo"
+
+# Auto-Reload after code modification
+# autoreload.on = True
+
+# Set to True if you'd like to abort execution if a controller gets an
+# unexpected parameter. False by default
+tg.strict_parameters = True
+
+# LOGGING
+# Logging configuration generally follows the style of the standard
+# Python logging module configuration. Note that when specifying
+# log format messages, you need to use *() for formatting variables.
+# Deployment independent log configuration is in dyndemo/config/log.cfg
+[logging]
+
+[[loggers]]
+[[[dyndemo]]]
+level='DEBUG'
+qualname='dyndemo'
+handlers=['debug_out']
+
+[[[allinfo]]]
+level='INFO'
+handlers=['debug_out']
+
+[[[access]]]
+level='INFO'
+qualname='turbogears.access'
+handlers=['access_out']
+propagate=0
+
+
+[[[database]]]
+# Set to INFO to make SQLAlchemy display SQL commands
+level='ERROR'
+qualname='sqlalchemy.engine'
+handlers=['debug_out']
+propagate=0

File dyndemo/devdata.sqlite

Binary file added.

File dyndemo/dyndemo.egg-info/PKG-INFO

+Metadata-Version: 1.0
+Name: dyndemo
+Version: 1.0
+Summary: UNKNOWN
+Home-page: UNKNOWN
+Author: UNKNOWN
+Author-email: UNKNOWN
+License: UNKNOWN
+Description: UNKNOWN
+Platform: UNKNOWN
+Classifier: Development Status :: 3 - Alpha
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Framework :: TurboGears

File dyndemo/dyndemo.egg-info/SOURCES.txt

+README.txt
+setup.py
+dyndemo/__init__.py
+dyndemo/commands.py
+dyndemo/controllers.py
+dyndemo/json.py
+dyndemo/model.py
+dyndemo/release.py
+dyndemo.egg-info/PKG-INFO
+dyndemo.egg-info/SOURCES.txt
+dyndemo.egg-info/dependency_links.txt
+dyndemo.egg-info/entry_points.txt
+dyndemo.egg-info/not-zip-safe
+dyndemo.egg-info/paster_plugins.txt
+dyndemo.egg-info/requires.txt
+dyndemo.egg-info/top_level.txt
+dyndemo/config/__init__.py
+dyndemo/templates/__init__.py
+dyndemo/tests/__init__.py
+dyndemo/tests/test_controllers.py
+dyndemo/tests/test_model.py

File dyndemo/dyndemo.egg-info/dependency_links.txt

+

File dyndemo/dyndemo.egg-info/entry_points.txt

+[console_scripts]
+start-dyndemo = dyndemo.commands:start
+

File dyndemo/dyndemo.egg-info/not-zip-safe

+

File dyndemo/dyndemo.egg-info/paster_plugins.txt

+TurboGears
+PasteScript

File dyndemo/dyndemo.egg-info/requires.txt

+TurboGears >= 1.0.4.4
+SQLAlchemy>=0.3.10
+Elixir>=0.4.0

File dyndemo/dyndemo.egg-info/top_level.txt

+dyndemo

File dyndemo/dyndemo/__init__.py

Empty file added.

File dyndemo/dyndemo/__init__.pyc

Binary file added.

File dyndemo/dyndemo/commands.py

+# -*- coding: utf-8 -*-
+"""This module contains functions called from console script entry points."""
+
+import sys
+from os import getcwd
+from os.path import dirname, exists, join
+
+import pkg_resources
+pkg_resources.require("TurboGears>=1.0.4.4")
+
+import cherrypy
+import turbogears
+
+cherrypy.lowercase_api = True
+
+
+class ConfigurationError(Exception):
+    pass
+
+
+def start():
+    """Start the CherryPy application server."""
+
+    setupdir = dirname(dirname(__file__))
+    curdir = getcwd()
+
+    # First look on the command line for a desired config file,
+    # if it's not on the command line, then look for 'setup.py'
+    # in the current directory. If there, load configuration
+    # from a file called 'dev.cfg'. If it's not there, the project
+    # is probably installed and we'll look first for a file called
+    # 'prod.cfg' in the current directory and then for a default
+    # config file called 'default.cfg' packaged in the egg.
+    if len(sys.argv) > 1:
+        configfile = sys.argv[1]
+    elif exists(join(setupdir, "setup.py")):
+        configfile = join(setupdir, "dev.cfg")
+    elif exists(join(curdir, "prod.cfg")):
+        configfile = join(curdir, "prod.cfg")
+    else:
+        try:
+            configfile = pkg_resources.resource_filename(
+              pkg_resources.Requirement.parse("dyndemo"),
+                "config/default.cfg")
+        except pkg_resources.DistributionNotFound:
+            raise ConfigurationError("Could not find default configuration.")
+
+    turbogears.update_config(configfile=configfile,
+        modulename="dyndemo.config")
+
+    from dyndemo.controllers import Root
+
+    turbogears.start_server(Root())

File dyndemo/dyndemo/commands.pyc

Binary file added.

File dyndemo/dyndemo/config/__init__.py

Empty file added.

File dyndemo/dyndemo/config/app.cfg

+[global]
+# The settings in this file should not vary depending on the deployment
+# environment. dev.cfg and prod.cfg are the locations for
+# the different deployment settings. Settings in this file will
+# be overridden by settings in those other files.
+
+# The commented out values below are the defaults
+
+# VIEW
+
+# which view (template engine) to use if one is not specified in the
+# template name
+# tg.defaultview = "kid"
+
+# The following kid settings determine the settings used by the kid serializer.
+
+# Kid output method (e.g. html, html-strict, xhtml, xhtml-strict, xml, json)
+# and formatting (e.g. default, straight, compact, newlines, wrap, nice)
+# kid.outputformat="html default"
+
+# kid.encoding="utf-8"
+
+# The sitetemplate is used for overall styling of a site that
+# includes multiple TurboGears applications
+# tg.sitetemplate="<packagename.templates.templatename>"
+
+# Allow every exposed function to be called as json,
+# tg.allow_json = False
+
+# Suppress the inclusion of the shipped MochiKit version, which is rather outdated.
+# Attention: setting this to True and listing 'turbogears.mochikit' in 'tg.include_widgets'
+# is a contradiction. This option will overrule the default-inclusion to prevent version
+# mismatch bugs.
+# tg.mochikit_suppress = True
+
+# List of Widgets to include on every page.
+# for example ['turbogears.mochikit']
+# tg.include_widgets = []
+
+# Set to True if the scheduler should be started
+# tg.scheduler = False
+
+# Set to True to allow paginate decorator redirects when page number gets
+# out of bound. Useful for getting the real page id in the url
+# paginate.redirect_on_out_of_range = True
+
+# Set to True to allow paginate decorator redirects when last page is requested.
+# This is useful for getting the real last page id in the url
+# paginate.redirect_on_last_page = True
+
+# Set session or cookie
+# session_filter.on = True
+
+
+# compress the data sends to the web browser
+# [/]
+# gzip_filter.on = True
+# gzip_filter.mime_types = ["application/x-javascript", "text/javascript", "text/html", "text/css", "text/plain"]
+
+[/static]
+static_filter.on = True
+static_filter.dir = "%(top_level_dir)s/static"
+
+[/favicon.ico]
+static_filter.on = True
+static_filter.file = "%(top_level_dir)s/static/images/favicon.ico"

File dyndemo/dyndemo/config/log.cfg

+# LOGGING
+# Logging is often deployment specific, but some handlers and
+# formatters can be defined here.
+
+[logging]
+[[formatters]]
+[[[message_only]]]
+format='*(message)s'
+
+[[[full_content]]]
+format='*(asctime)s *(name)s *(levelname)s *(message)s'
+
+[[handlers]]
+[[[debug_out]]]
+class='StreamHandler'
+level='DEBUG'
+args='(sys.stdout,)'
+formatter='full_content'
+
+[[[access_out]]]
+class='StreamHandler'
+level='INFO'
+args='(sys.stdout,)'
+formatter='message_only'
+
+[[[error_out]]]
+class='StreamHandler'
+level='ERROR'
+args='(sys.stdout,)'

File dyndemo/dyndemo/controllers.py

+import turbogears as tg
+from turbogears import controllers, expose, flash
+import toscawidgets.widgets.dynforms as twd
+import toscawidgets.widgets.forms as twf
+from dyndemo import model
+import formencode as fe, toscawidgets.api as tw
+# import logging
+# log = logging.getLogger("dyndemo.controllers")
+
+
+class FilteringSchema(fe.Schema):
+    filter_extra_fields = True
+    allow_extra_fields = True
+
+
+class OrderList(twd.SmartList):
+    datasrc = model.Order
+    columns = \
+    [
+        ('link', ''),
+        ('title', 'Title'),
+        ('service', 'Service'),
+        ('value', 'Value'),
+    ]
+    data_filter = ['service']
+    search_cols = ['title']
+orderlist = OrderList('fred', None)
+
+orderform = twf.TableForm('order', action='save_order', validator=FilteringSchema, children=[
+    tw.Child(twf.LabelHiddenField, 'id'),
+    tw.Child(twf.TextField, 'title'),
+    tw.Child(twd.OtherSingleSelectField, 'cust_id', dataobj=model.Customer, field='name'),
+    tw.Child(twf.TextField, 'service'),
+    tw.Child(twf.TextField, 'value', validator=fe.validators.Int),
+    tw.Child(twd.HidingSingleSelectField, 'ordtype', options=[('',''), (1,'Hardware'), (2,'Software')], mapping={1:['location'], 2:['os']}),
+    tw.Child(twf.TextField, 'location'),
+    tw.Child(twf.TextField, 'os'),
+    tw.Child(twd.WriteOnlyTextField, 'ccnum'),
+    tw.Child(twd.GrowableTableFieldSet, 'parts', children = [
+        tw.Child(twf.TextField, 'name'),
+        tw.Child(twf.TextField, 'detail'),
+        tw.Child(twf.TextField, 'price', validator=fe.validators.Int),
+    ]),    
+])   
+
+
+class Root(controllers.RootController):
+
+    @tg.expose(template="dyndemo.templates.orders")
+    def index(self, **kw):
+        return dict(orderlist=orderlist, kw=kw)
+
+    @tg.expose(template="dyndemo.templates.order")
+    def order(self, id):
+        return dict(orderform=orderform, order=model.Order.get(id))
+
+    @tg.expose()
+    @tg.validate(orderform)
+    @tg.error_handler(order)
+    def save_order(self, id, **kw):
+        order = id and model.Order.get(id) or model.Order()
+        twd.proc_hash(order, twd.strip_wo_markers(kw))
+        raise tg.redirect('/')

File dyndemo/dyndemo/controllers.pyc

Binary file added.

File dyndemo/dyndemo/json.py

+# A JSON-based API(view) for your app.
+# Most rules would look like:
+# @jsonify.when("isinstance(obj, YourClass)")
+# def jsonify_yourclass(obj):
+#     return [obj.val1, obj.val2]
+# @jsonify can convert your objects to following types:
+# lists, dicts, numbers and strings
+
+from turbojson.jsonify import jsonify
+

File dyndemo/dyndemo/model.py

+import pkg_resources
+pkg_resources.require("SQLAlchemy>=0.3.10")
+pkg_resources.require("Elixir>=0.4.0")
+# import the basic Elixir classes and functions for declaring the data model
+# (see http://elixir.ematia.de/trac/wiki/TutorialDivingIn)
+from elixir import Entity, Field, OneToMany, ManyToOne, ManyToMany
+from elixir import options_defaults, using_options, setup_all
+# import some datatypes for table columns from Elixir
+# (see http://www.sqlalchemy.org/docs/04/types.html for more)
+from elixir import String, Unicode, Integer, DateTime
+import genshi
+
+options_defaults['autosetup'] = False
+
+
+# your data model
+
+class Customer(Entity):
+    name = Field(String(100))
+    def __str__(self):
+        return self.name
+
+class Order(Entity):
+    title = Field(String(100))
+    cust = ManyToOne(Customer)
+    service = Field(String(100))
+    value = Field(Integer)    
+    ordtype = Field(Integer)
+    location = Field(String(100))
+    os = Field(String(100))        
+    ccnum = Field(String(100))
+    
+    @property
+    def link(self):
+        return genshi.XML('<a href="order?id=%s">View</a>' % self.id)
+
+class Part(Entity):
+    order = ManyToOne(Order, backref='parts')
+    name = Field(String(100))
+    detail = Field(String(100))
+    price = Field(Integer)
+
+    
+setup_all()

File dyndemo/dyndemo/model.pyc

Binary file added.

File dyndemo/dyndemo/release.py

+# Release information about dyndemo
+
+version = "1.0"
+
+# description = "Your plan to rule the world"
+# long_description = "More description about your plan"
+# author = "Your Name Here"
+# email = "YourEmail@YourDomain"
+# copyright = "Vintage 2006 - a good year indeed"
+
+# if it's open source, you might want to specify these
+# url = "http://yourcool.site/"
+# download_url = "http://yourcool.site/download"
+# license = "MIT"

File dyndemo/dyndemo/static/css/style.css

+/*
+ * Quick mash-up of CSS for the TG quick start page.
+ */
+
+html, body {
+  color: black;
+  background-color: #ddd;
+  font: x-small "Lucida Grande", "Lucida Sans Unicode", geneva, verdana, sans-serif;
+  margin: 0;
+  padding: 0;
+}
+
+td, th {padding:3px;border:none;}
+tr th {text-align:left;background-color:#f0f0f0;color:#333;}
+tr.odd td {background-color:#edf3fe;}
+tr.even td {background-color:#fff;}
+
+#header {
+  height: 80px;
+  width: 777px;
+  background: blue URL('../images/header_inner.png') no-repeat;
+  border-left: 1px solid #aaa;
+  border-right: 1px solid #aaa;
+  margin: 0 auto 0 auto;
+}
+
+a.link, a, a.active {
+  color: #369;
+}
+
+
+#main_content {
+  color: black;
+  font-size: 127%;
+  background-color: white;
+  width: 757px;
+  margin: 0 auto 0 auto;
+  border-left: 1px solid #aaa;
+  border-right: 1px solid #aaa;
+  padding: 10px;
+}
+
+#sidebar {
+  border: 1px solid #aaa;
+  background-color: #eee;
+  margin: 0.5em;
+  padding: 1em;
+  float: right;
+  width: 200px;
+  font-size: 88%;
+}
+
+#sidebar h2 {
+  margin-top: 0;
+}
+
+#sidebar ul {
+  margin-left: 1.5em;
+  padding-left: 0;
+}
+
+h1,h2,h3,h4,h5,h6,#getting_started_steps {
+  font-family: "Century Schoolbook L", Georgia, serif;
+  font-weight: bold;
+}
+
+h2 {
+  font-size: 150%;
+}
+
+#getting_started_steps a {
+  text-decoration: none;
+}
+
+#getting_started_steps a:hover {
+  text-decoration: underline;
+}
+
+#getting_started_steps li {
+  font-size: 80%;
+  margin-bottom: 0.5em;
+}
+
+#getting_started_steps h2 {
+  font-size: 120%;
+}
+
+#getting_started_steps p {
+  font: 100% "Lucida Grande", "Lucida Sans Unicode", geneva, verdana, sans-serif;
+}
+
+#footer {
+  border: 1px solid #aaa;
+  border-top: 0px none;
+  color: #999;
+  background-color: white;
+  padding: 10px;
+  font-size: 80%;
+  text-align: center;
+  width: 757px;
+  margin: 0 auto 1em auto;
+}
+
+.code {
+  font-family: monospace;
+}
+
+span.code {
+  font-weight: bold;
+  background: #eee;
+}
+
+#status_block {
+  margin: 0 auto 0.5em auto;
+  padding: 15px 10px 15px 55px;
+  background: #cec URL('../images/ok.png') left center no-repeat;
+  border: 1px solid #9c9;
+  width: 450px;
+  font-size: 120%;
+  font-weight: bolder;
+}
+
+.notice {
+  margin: 0.5em auto 0.5em auto;
+  padding: 15px 10px 15px 55px;
+  width: 450px;
+  background: #eef URL('../images/info.png') left center no-repeat;
+  border: 1px solid #cce;
+}
+
+.fielderror {
+    color: red;
+    font-weight: bold;
+}

File dyndemo/dyndemo/static/images/favicon.ico

Added
New image

File dyndemo/dyndemo/static/images/header_inner.png

Added
New image

File dyndemo/dyndemo/static/images/info.png

Added
New image

File dyndemo/dyndemo/static/images/ok.png

Added
New image

File dyndemo/dyndemo/static/images/tg_under_the_hood.png

Added
New image

File dyndemo/dyndemo/static/images/under_the_hood_blue.png

Added
New image

File dyndemo/dyndemo/templates/__init__.py

Empty file added.

File dyndemo/dyndemo/templates/__init__.pyc

Binary file added.

File dyndemo/dyndemo/templates/login.kid

+<!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://purl.org/kid/ns#">
+
+<head>
+    <meta content="text/html; charset=UTF-8"
+        http-equiv="content-type" py:replace="''"/>
+    <title>Login</title>
+    <style type="text/css">
+        #loginBox
+        {
+            width: 30%;
+            margin: auto;
+            margin-top: 10%;
+            padding-left: 10%;
+            padding-right: 10%;
+            padding-top: 5%;
+            padding-bottom: 5%;
+            font-family: verdana;
+            font-size: 10px;
+            background-color: #eee;
+            border: 2px solid #ccc;
+        }
+
+        #loginBox h1
+        {
+            font-size: 42px;
+            font-family: "Trebuchet MS";
+            margin: 0;
+            color: #ddd;
+        }
+
+        #loginBox p
+        {
+            position: relative;
+            top: -1.5em;
+            padding-left: 4em;
+            font-size: 12px;
+            margin: 0;
+            color: #666;
+        }
+
+        #loginBox table
+        {
+            table-layout: fixed;
+            border-spacing: 0;
+            width: 100%;
+        }
+
+        #loginBox td.label
+        {
+            width: 33%;
+            text-align: right;
+        }
+
+        #loginBox td.field
+        {
+            width: 66%;
+        }
+
+        #loginBox td.field input
+        {
+            width: 100%;
+        }
+
+        #loginBox td.buttons
+        {
+            text-align: right;
+        }
+
+    </style>
+</head>
+
+<body>
+    <div id="loginBox">
+        <h1>Login</h1>
+        <p>${message}</p>
+        <form action="${previous_url}" method="POST">
+            <table>
+                <tr>
+                    <td class="label">
+                        <label for="user_name">User Name:</label>
+                    </td>
+                    <td class="field">
+                        <input type="text" id="user_name" name="user_name"/>
+                    </td>
+                </tr>
+                <tr>
+                    <td class="label">
+                        <label for="password">Password:</label>
+                    </td>
+                    <td class="field">
+                        <input type="password" id="password" name="password"/>
+                    </td>
+                </tr>
+                <tr>
+                    <td colspan="2" class="buttons">
+                        <input type="submit" name="login" value="Login"/>
+                    </td>
+                </tr>
+            </table>
+
+            <input py:if="forward_url" type="hidden" name="forward_url"
+                value="${forward_url}"/>
+                
+            <div py:for="name,values in original_parameters.items()" py:strip="1">
+            <input py:for="value in isinstance(values, list) and values or [values]"
+                type="hidden" name="${name}" value="${value}"/>
+            </div>
+        </form>
+    </div>
+</body>
+</html>

File dyndemo/dyndemo/templates/master.kid

+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?python import sitetemplate ?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
+    py:extends="sitetemplate">
+
+<head py:match="item.tag=='{http://www.w3.org/1999/xhtml}head'" py:attrs="item.items()">
+    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
+    <title py:replace="''">Your title goes here</title>
+    <meta py:replace="item[:]" name="description" content="master template"/>
+    <style type="text/css" media="screen">
+        #pageLogin
+        {
+            font-size: 10px;
+            font-family: verdana;
+            text-align: right;
+        }
+    </style>
+    <link rel="stylesheet" type="text/css" media="screen" href="../static/css/style.css"
+        py:attrs="href=tg.url('/static/css/style.css')"/>
+</head>
+
+<body py:match="item.tag=='{http://www.w3.org/1999/xhtml}body'" py:attrs="item.items()">
+    <div py:if="tg.config('identity.on') and not defined('logging_in')" id="pageLogin">
+        <span py:if="tg.identity.anonymous">
+            <a href="${tg.url('/login')}">Login</a>
+        </span>
+        <span py:if="not tg.identity.anonymous">
+            Welcome ${tg.identity.user.display_name or tg.identity.user.user_name}.
+            <a href="${tg.url('/logout')}">Logout</a>
+        </span>
+    </div>
+
+    <div id="header">&#160;</div>
+
+    <div id="main_content">
+        <div id="status_block" class="flash"
+            py:if="value_of('tg_flash', None)" py:content="tg_flash"></div>
+        <div py:replace="[item.text]+item[:]">page content</div>
+    </div>
+
+    <div id="footer">
+        <img src="${tg.url('/static/images/under_the_hood_blue.png')}"
+            alt="TurboGears under the hood" />
+        <p>TurboGears is a open source front-to-back web development framework
+            written in Python</p>
+        <p>Copyright &#169; 2007 Kevin Dangoor</p>
+    </div>
+</body>
+
+</html>

File dyndemo/dyndemo/templates/master.pyc

Binary file added.

File dyndemo/dyndemo/templates/order.kid

+<!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://purl.org/kid/ns#"
+    py:extends="'master.kid'">
+<head>
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type" py:replace="''"/>
+<title>Welcome to TurboGears</title>
+</head>
+<body>
+
+${orderform(order)}
+
+</body>
+</html>

File dyndemo/dyndemo/templates/order.pyc

Binary file added.

File dyndemo/dyndemo/templates/orders.kid

+<!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://purl.org/kid/ns#"
+    py:extends="'master.kid'">
+<head>
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type" py:replace="''"/>
+<title>Welcome to TurboGears</title>
+</head>
+<body>
+
+<a href="order?id=NEW">New Order</a>
+
+${orderlist(kw)}
+
+</body>
+</html>

File dyndemo/dyndemo/templates/orders.pyc

Binary file added.

File dyndemo/dyndemo/templates/welcome.kid

+<!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://purl.org/kid/ns#"
+    py:extends="'master.kid'">
+<head>
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type" py:replace="''"/>
+<title>Welcome to TurboGears</title>
+</head>
+<body>
+
+  <div id="sidebar">
+    <h2>Learn more</h2>
+    Learn more about TurboGears and take part in its
+    development
+    <ul class="links">
+      <li><a href="http://www.turbogears.org">Official website</a></li>
+      <li><a href="http://docs.turbogears.org">Documentation</a></li>
+      <li><a href="http://trac.turbogears.org/turbogears/">Trac
+        (bugs/suggestions)</a></li>
+      <li><a href="http://groups.google.com/group/turbogears"> Mailing list</a> </li>
+    </ul>
+    <span py:replace="now">now</span>
+  </div>
+  <div id="getting_started">
+    <ol id="getting_started_steps">
+      <li class="getting_started">
+        <h3>Model</h3>
+        <p> <a href="http://docs.turbogears.org/1.0/GettingStarted/DefineDatabase">Design models</a> in the <span class="code">model.py</span>.<br/>
+          Edit <span class="code">dev.cfg</span> to <a href="http://docs.turbogears.org/1.0/GettingStarted/UseDatabase">use a different backend</a>, or start with a pre-configured SQLite database. <br/>
+          Use script <span class="code">tg-admin sql create</span> to create the database tables.</p>
+      </li>
+      <li class="getting_started">
+        <h3>View</h3>
+        <p> Edit <a href="http://docs.turbogears.org/1.0/GettingStarted/Kid">html-like templates</a> in the <span class="code">/templates</span> folder;<br/>
+        Put all <a href="http://docs.turbogears.org/1.0/StaticFiles">static contents</a> in the <span class="code">/static</span> folder. </p>
+      </li>
+      <li class="getting_started">
+        <h3>Controller</h3>
+        <p> Edit <span class="code"> controllers.py</span> and <a href="http://docs.turbogears.org/1.0/GettingStarted/CherryPy">build your
+          website structure</a> with the simplicity of Python objects. <br/>
+          TurboGears will automatically reload itself when you modify your project. </p>
+      </li>
+    </ol>
+    <div class="notice"> If you create something cool, please <a href="http://groups.google.com/group/turbogears">let people know</a>, and consider contributing something back to the <a href="http://groups.google.com/group/turbogears">community</a>.</div>
+  </div>
+  <!-- End of getting_started -->
+</body>
+</html>

File dyndemo/dyndemo/tests/__init__.py

Empty file added.

File dyndemo/dyndemo/tests/test_controllers.py

+import unittest
+import turbogears
+from turbogears import testutil
+from dyndemo.controllers import Root
+import cherrypy
+
+cherrypy.root = Root()
+
+class TestPages(unittest.TestCase):
+
+    def setUp(self):
+        turbogears.startup.startTurboGears()
+
+    def tearDown(self):
+        """Tests for apps using identity need to stop CP/TG after each test to
+        stop the VisitManager thread.
+        See http://trac.turbogears.org/turbogears/ticket/1217 for details.
+        """
+        turbogears.startup.stopTurboGears()
+
+    def test_method(self):
+        "the index method should return a string called now"
+        import types
+        result = testutil.call(cherrypy.root.index)
+        assert type(result["now"]) == types.StringType
+
+    def test_indextitle(self):
+        "The indexpage should have the right title"
+        testutil.create_request("/")
+        response = cherrypy.response.body[0].lower()
+        assert "<title>welcome to turbogears</title>" in response
+

File dyndemo/dyndemo/tests/test_model.py

+# If your project uses a database, you can set up database tests
+# similar to what you see below. Be sure to set the db_uri to
+# an appropriate uri for your testing database. sqlite is a good
+# choice for testing, because you can use an in-memory database
+# which is very fast.
+
+from turbogears import testutil, database
+# from dyndemo.model import YourDataClass, User
+
+# database.set_db_uri("sqlite:///:memory:")
+
+# class TestUser(testutil.DBTest):
+#     def get_model(self):
+#         return User
+#     def test_creation(self):
+#         "Object creation should set the name"
+#         obj = User(user_name = "creosote",
+#                       email_address = "spam@python.not",
+#                       display_name = "Mr Creosote",
+#                       password = "Wafer-thin Mint")
+#         assert obj.display_name == "Mr Creosote"
+

File dyndemo/sample-prod.cfg

+[global]
+# This is where all of your settings go for your production environment.
+# You'll copy this file over to your production server and provide it
+# as a command-line option to your start script.
+# Settings that are the same for both development and production
+# (such as template engine, encodings, etc.) all go in 
+# dyndemo/config/app.cfg
+
+# DATABASE
+
+# driver://username:password@host:port/database
+
+# pick the form for your database
+# sqlalchemy.dburi="postgres://username@hostname/databasename"
+# sqlalchemy.dburi="mysql://username:password@hostname:port/databasename"
+# sqlalchemy.dburi="sqlite:///file_name_and_path"
+
+# If you have sqlite, here's a simple default to get you started
+# in development
+sqlalchemy.dburi="sqlite:///%(current_dir_uri)s/devdata.sqlite"
+
+
+# SERVER
+
+server.environment="production"
+
+# Sets the number of threads the server uses
+# server.thread_pool = 1
+
+# if this is part of a larger site, you can set the path
+# to the TurboGears instance here
+# server.webpath=""
+
+# Set to True if you are deploying your App behind a proxy
+# e.g. Apache using mod_proxy
+# base_url_filter.on = False
+
+# Set to True if your proxy adds the x_forwarded_host header
+# base_url_filter.use_x_forwarded_host = True
+
+# If your proxy does not add the x_forwarded_host header, set
+# the following to the *public* host url.
+# (Note: This will be overridden by the use_x_forwarded_host option
+# if it is set to True and the proxy adds the header correctly.
+# base_url_filter.base_url = "http://www.example.com"
+
+# Set to True if you'd like to abort execution if a controller gets an
+# unexpected parameter. False by default
+# tg.strict_parameters = False
+
+# LOGGING
+# Logging configuration generally follows the style of the standard
+# Python logging module configuration. Note that when specifying
+# log format messages, you need to use *() for formatting variables.
+# Deployment independent log configuration is in dyndemo/config/log.cfg
+[logging]
+
+[[handlers]]
+
+[[[access_out]]]
+# set the filename as the first argument below
+args="('server.log',)"
+class='FileHandler'
+level='INFO'
+formatter='message_only'
+
+[[loggers]]
+[[[dyndemo]]]
+level='ERROR'
+qualname='dyndemo'
+handlers=['error_out']
+
+[[[access]]]
+level='INFO'
+qualname='turbogears.access'
+handlers=['access_out']
+propagate=0

File dyndemo/setup.py

+# -*- coding: utf-8 -*-
+
+from setuptools import setup, find_packages
+from turbogears.finddata import find_package_data
+
+import os
+execfile(os.path.join("dyndemo", "release.py"))
+
+packages=find_packages()
+package_data = find_package_data(where='dyndemo',
+    package='dyndemo')
+if os.path.isdir('locales'):
+    packages.append('locales')
+    package_data.update(find_package_data(where='locales',
+        exclude=('*.po',), only_in_packages=False))
+
+setup(
+    name="dyndemo",
+    version=version,
+    # uncomment the following lines if you fill them out in release.py
+    #description=description,
+    #author=author,
+    #author_email=email,
+    #url=url,
+    #download_url=download_url,
+    #license=license,
+
+    install_requires=[
+        "TurboGears >= 1.0.4.4",
+        "SQLAlchemy>=0.3.10",
+        "Elixir>=0.4.0",
+    ],
+    zip_safe=False,
+    packages=packages,
+    package_data=package_data,
+    keywords=[
+        # Use keywords if you'll be adding your package to the
+        # Python Cheeseshop
+
+        # if this has widgets, uncomment the next line
+        # 'turbogears.widgets',
+
+        # if this has a tg-admin command, uncomment the next line
+        # 'turbogears.command',
+
+        # if this has identity providers, uncomment the next line
+        # 'turbogears.identity.provider',
+
+        # If this is a template plugin, uncomment the next line
+        # 'python.templating.engines',
+
+        # If this is a full application, uncomment the next line
+        # 'turbogears.app',
+    ],
+    classifiers=[
+        'Development Status :: 3 - Alpha',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python',
+        'Topic :: Software Development :: Libraries :: Python Modules',
+        'Framework :: TurboGears',
+        # if this is an application that you'll distribute through
+        # the Cheeseshop, uncomment the next line
+        # 'Framework :: TurboGears :: Applications',
+
+        # if this is a package that includes widgets that you'll distribute
+        # through the Cheeseshop, uncomment the next line
+        # 'Framework :: TurboGears :: Widgets',
+    ],
+    test_suite='nose.collector',
+    entry_points = {
+        'console_scripts': [
+            'start-dyndemo = dyndemo.commands:start',
+        ],
+    },
+    # Uncomment next line and create a default.cfg file in your project dir
+    # if you want to package a default configuration in your egg.
+    #data_files = [('config', ['default.cfg'])],
+    )

File dyndemo/setup.pyc

Binary file added.

File dyndemo/start-dyndemo.py

+#!C:\Python24\python.exe
+# -*- coding: utf-8 -*-
+"""Start script for the dyndemo TurboGears project.
+
+This script is only needed during development for running from the project
+directory. When the project is installed, easy_install will create a
+proper start script.
+"""
+
+import sys
+from dyndemo.commands import start, ConfigurationError
+
+if __name__ == "__main__":
+    try:
+        start()
+    except ConfigurationError, exc:
+        sys.stderr.write(str(exc))
+        sys.exit(1)

File dyndemo/test.cfg

+[global]
+# You can place test-specific configuration options here (like test db uri, etc)
+
+# DATABASE
+
+sqlalchemy.dburi = "sqlite:///:memory:"
+
+# LOGGING
+
+[logging]
+
+[[formatters]]
+[[[full_content]]]
+format='*(asctime)s *(name)s *(levelname)s *(message)s'
+
+[[handlers]]
+[[[test_out]]]
+class='StreamHandler'
+level='DEBUG'
+args='(sys.stdout,)'
+formatter='full_content'
+
+[[loggers]]
+[[[dyndemo]]]
+level='DEBUG'
+qualname='dyndemo'
+handlers=['test_out']
+
+[[[turbogears]]]
+level='INFO'
+qualname='turbogears'
+handlers=['test_out']

File toscawidgets/widgets/dynforms/widgets.py

 import toscawidgets.api as tw, toscawidgets.widgets.forms as twf
-import sqlalchemy as sa, formencode as fe, turbojson
+import sqlalchemy as sa, sqlalchemy.orm as sao, formencode as fe, turbojson
 
 __all__ = ['SmartList', 'WriteOnlyTextField', 'strip_wo_markers',
            'HidingSingleSelectField', 'IntNull', 'load_options',
             self.src_clear = twf.SubmitButton('src_clear', self, default='Clear', attrs={'onclick':"document.getElementById('%s').value=''" % self.src_text.id})
 
 
-    def update_params(self, params):
+    def update_params(self, params):    
+        if not params['value']:
+            params['value'] = {}
 
         # generate appropriate query constraints from filters
         conds = list(self.conds)
     template = 'toscawidgets.widgets.dynforms.templates.table_field_set'
     validator = StripGrow
 
-    def __new__(cls, id=None, parent=None, children=[], **kw):
-        children.append(tw.Child(DelUndo, 'delundo'))
-        children.append(tw.Child(twf.HiddenField, 'id', validator=fe.validators.Int))
+    def __new__(cls, id=None, parent=None, children=[], **kw):        
+        #children.append(tw.Child(DelUndo, 'delundo'))
+        #children.append(tw.Child(twf.HiddenField, 'id', validator=fe.validators.Int))
+        children.append(DelUndo('delundo'))
+        children.append(twf.HiddenField('id', validator=fe.validators.Int))
         children = [tw.Child(StrippingFieldRepeater, 'grow', widget=TrFieldSet('row', children=children))]
         return twf.FieldSet.__new__(cls, id, parent, children, **kw)
 

File toscawidgets/widgets/dynforms/widgets.pyc

Binary file modified.