From ab91d92af32aed77469fafbb581feb07239b7a60 Mon Sep 17 00:00:00 2001
From: Jan Dittberner <jan@dittberner.info>
Date: Sun, 5 Oct 2008 19:02:55 +0000
Subject: [PATCH] maintenance work  * remove generated template python code
 (fixes #6)  * add an index controller and make it the default (addresses #5) 
 * add a dependency to sqlalchemy-migrate (fixes #4, addresses #2)

git-svn-id: file:///var/www/wwwusers/usr01/svn/pyalchemybiz/trunk@6 389c73d4-bf09-4d3d-a15e-f94a37d0667a
---
 data/templates/base.mako.py                 |  45 --------
 data/templates/customer.mako.py             |  50 ---------
 development.ini                             |   1 +
 pyalchemybiz.egg-info/PKG-INFO              |  10 +-
 pyalchemybiz.egg-info/SOURCES.txt           |  14 ++-
 pyalchemybiz.egg-info/requires.txt          |   4 +-
 pyalchemybiz/config/routing.py              |   2 +-
 pyalchemybiz/controllers/index.py           |  13 +++
 pyalchemybiz/public/index.html              | 108 --------------------
 pyalchemybiz/templates/base.mako            |   2 +-
 pyalchemybiz/templates/index.mako           |   3 +
 pyalchemybiz/tests/functional/test_index.py |   7 ++
 setup.py                                    |   3 +-
 test.ini                                    |   3 +
 14 files changed, 52 insertions(+), 213 deletions(-)
 delete mode 100644 data/templates/base.mako.py
 delete mode 100644 data/templates/customer.mako.py
 create mode 100644 pyalchemybiz/controllers/index.py
 delete mode 100644 pyalchemybiz/public/index.html
 create mode 100644 pyalchemybiz/templates/index.mako
 create mode 100644 pyalchemybiz/tests/functional/test_index.py

diff --git a/data/templates/base.mako.py b/data/templates/base.mako.py
deleted file mode 100644
index 0349a7a..0000000
--- a/data/templates/base.mako.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from mako import runtime, filters, cache
-UNDEFINED = runtime.UNDEFINED
-__M_dict_builtin = dict
-__M_locals_builtin = locals
-_magic_number = 4
-_modified_time = 1223071301.6449161
-_template_filename=u'/home/jan/src/pyalchemybiz/pyalchemybiz/templates/base.mako'
-_template_uri=u'/base.mako'
-_template_cache=cache.Cache(__name__, _modified_time)
-_source_encoding=None
-_exports = []
-
-
-def render_body(context,**pageargs):
-    context.caller_stack._push_frame()
-    try:
-        __M_locals = __M_dict_builtin(pageargs=pageargs)
-        h = context.get('h', UNDEFINED)
-        next = context.get('next', UNDEFINED)
-        __M_writer = context.writer()
-        # SOURCE LINE 1
-        __M_writer(u'<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1//EN"\n          "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n<html>\n  <head>\n    <title>PyAlchemyBiz</title>\n    ')
-        # SOURCE LINE 6
-        __M_writer(unicode(h.stylesheet_link_tag('/pyalchemybiz.css')))
-        __M_writer(u'\n    ')
-        # SOURCE LINE 7
-        __M_writer(unicode(h.javascript_include_tag(
-        '/javascripts/pyalchemybiz.js', builtins=True)))
-        # SOURCE LINE 8
-        __M_writer(u'\n  </head>\n  <body>\n    <div class="content">\n      ')
-        # SOURCE LINE 12
-        __M_writer(unicode(next.body()))
-        __M_writer(u'')
-        # SOURCE LINE 13
-        __M_writer(u'      <p class="footer">\n        Return to the\n        ')
-        # SOURCE LINE 15
-        __M_writer(unicode(h.link_to('FrontPage',
-            h.url_for(action="index"))))
-        # SOURCE LINE 16
-        __M_writer(u'\n      </p>\n    </div>\n  </body>\n</html>\n')
-        return ''
-    finally:
-        context.caller_stack._pop_frame()
-
-
diff --git a/data/templates/customer.mako.py b/data/templates/customer.mako.py
deleted file mode 100644
index a7cc270..0000000
--- a/data/templates/customer.mako.py
+++ /dev/null
@@ -1,50 +0,0 @@
-from mako import runtime, filters, cache
-UNDEFINED = runtime.UNDEFINED
-__M_dict_builtin = dict
-__M_locals_builtin = locals
-_magic_number = 4
-_modified_time = 1223072023.421654
-_template_filename='/home/jan/src/pyalchemybiz/pyalchemybiz/templates/customer.mako'
-_template_uri='/customer.mako'
-_template_cache=cache.Cache(__name__, _modified_time)
-_source_encoding=None
-_exports = []
-
-
-def _mako_get_namespace(context, name):
-    try:
-        return context.namespaces[(__name__, name)]
-    except KeyError:
-        _mako_generate_namespaces(context)
-        return context.namespaces[(__name__, name)]
-def _mako_generate_namespaces(context):
-    pass
-def _mako_inherit(template, context):
-    _mako_generate_namespaces(context)
-    return runtime._inherit_from(context, u'base.mako', _template_uri)
-def render_body(context,**pageargs):
-    context.caller_stack._push_frame()
-    try:
-        __M_locals = __M_dict_builtin(pageargs=pageargs)
-        h = context.get('h', UNDEFINED)
-        c = context.get('c', UNDEFINED)
-        __M_writer = context.writer()
-        # SOURCE LINE 1
-        __M_writer(u'\n\n<h1>Hallo</h1>\n\n<ul id="customers">\n')
-        # SOURCE LINE 6
-        for customer in c.customers:
-            # SOURCE LINE 7
-            __M_writer(u' <li>')
-            __M_writer(unicode(customer.firstname))
-            __M_writer(u'&nbsp;')
-            __M_writer(unicode(customer.lastname))
-            __M_writer(u' [')
-            __M_writer(unicode(h.link_to('edit', h.url_for(id=customer.id, action="edit"))))
-            __M_writer(u']</li>\n')
-        # SOURCE LINE 9
-        __M_writer(u'</ul>\n')
-        return ''
-    finally:
-        context.caller_stack._pop_frame()
-
-
diff --git a/development.ini b/development.ini
index 4e8ce6a..acf16ee 100644
--- a/development.ini
+++ b/development.ini
@@ -38,6 +38,7 @@ beaker.session.secret = somesecret
 # invalidate the URI when specifying a SQLite db via path name
 sqlalchemy.default.url = sqlite:///%(here)s/pyalchemybiz.db
 sqlalchemy.default.echo = true
+sqlalchemy.convert_unicode = true
 
 
 # Logging configuration
diff --git a/pyalchemybiz.egg-info/PKG-INFO b/pyalchemybiz.egg-info/PKG-INFO
index ad177e1..957496c 100644
--- a/pyalchemybiz.egg-info/PKG-INFO
+++ b/pyalchemybiz.egg-info/PKG-INFO
@@ -1,10 +1,10 @@
 Metadata-Version: 1.0
 Name: pyalchemybiz
-Version: 0.0.0dev
-Summary: UNKNOWN
-Home-page: UNKNOWN
-Author: UNKNOWN
-Author-email: UNKNOWN
+Version: 0.1dev-r5
+Summary: python based small business suite.
+Home-page: http://www.dittberner.info/projects/pyalchemybiz
+Author: Jan Dittberner
+Author-email: jan@dittberner.info
 License: UNKNOWN
 Description: UNKNOWN
 Platform: UNKNOWN
diff --git a/pyalchemybiz.egg-info/SOURCES.txt b/pyalchemybiz.egg-info/SOURCES.txt
index 6be95e1..fd8780f 100644
--- a/pyalchemybiz.egg-info/SOURCES.txt
+++ b/pyalchemybiz.egg-info/SOURCES.txt
@@ -1,7 +1,12 @@
 MANIFEST.in
 README.txt
+development.ini
 setup.cfg
 setup.py
+test.ini
+data/templates/base.mako.py
+data/templates/customer.mako.py
+docs/index.txt
 pyalchemybiz/__init__.py
 pyalchemybiz/websetup.py
 pyalchemybiz.egg-info/PKG-INFO
@@ -9,6 +14,7 @@ pyalchemybiz.egg-info/SOURCES.txt
 pyalchemybiz.egg-info/dependency_links.txt
 pyalchemybiz.egg-info/entry_points.txt
 pyalchemybiz.egg-info/paste_deploy_config.ini_tmpl
+pyalchemybiz.egg-info/paster_plugins.txt
 pyalchemybiz.egg-info/requires.txt
 pyalchemybiz.egg-info/top_level.txt
 pyalchemybiz/config/__init__.py
@@ -16,6 +22,7 @@ pyalchemybiz/config/environment.py
 pyalchemybiz/config/middleware.py
 pyalchemybiz/config/routing.py
 pyalchemybiz/controllers/__init__.py
+pyalchemybiz/controllers/customer.py
 pyalchemybiz/controllers/error.py
 pyalchemybiz/controllers/template.py
 pyalchemybiz/lib/__init__.py
@@ -23,7 +30,12 @@ pyalchemybiz/lib/app_globals.py
 pyalchemybiz/lib/base.py
 pyalchemybiz/lib/helpers.py
 pyalchemybiz/model/__init__.py
+pyalchemybiz/model/customer.py
+pyalchemybiz/model/meta.py
 pyalchemybiz/public/index.html
+pyalchemybiz/templates/base.mako
+pyalchemybiz/templates/customer.mako
 pyalchemybiz/tests/__init__.py
 pyalchemybiz/tests/test_models.py
-pyalchemybiz/tests/functional/__init__.py
\ No newline at end of file
+pyalchemybiz/tests/functional/__init__.py
+pyalchemybiz/tests/functional/test_customer.py
\ No newline at end of file
diff --git a/pyalchemybiz.egg-info/requires.txt b/pyalchemybiz.egg-info/requires.txt
index fe9f093..2994bc9 100644
--- a/pyalchemybiz.egg-info/requires.txt
+++ b/pyalchemybiz.egg-info/requires.txt
@@ -1 +1,3 @@
-Pylons>=0.9.6.2
\ No newline at end of file
+Pylons>=0.9.6.2
+SQLAlchemy>=0.4.7
+sqlalchemy-migrate>=0.4.5
\ No newline at end of file
diff --git a/pyalchemybiz/config/routing.py b/pyalchemybiz/config/routing.py
index af711a9..1d42332 100644
--- a/pyalchemybiz/config/routing.py
+++ b/pyalchemybiz/config/routing.py
@@ -17,7 +17,7 @@ def make_map():
     map.connect('error/:action/:id', controller='error')
 
     # CUSTOM ROUTES HERE
-
+    map.connect('', controller='index', action='index')
     map.connect(':controller/:action/:id')
     map.connect('*url', controller='template', action='view')
 
diff --git a/pyalchemybiz/controllers/index.py b/pyalchemybiz/controllers/index.py
new file mode 100644
index 0000000..7d63df0
--- /dev/null
+++ b/pyalchemybiz/controllers/index.py
@@ -0,0 +1,13 @@
+import logging
+
+from pyalchemybiz.lib.base import *
+
+log = logging.getLogger(__name__)
+
+class IndexController(BaseController):
+
+    def index(self):
+        # Return a rendered template
+        #   return render('/some/template.mako')
+        # or, Return a response
+        return render('/index.mako')
diff --git a/pyalchemybiz/public/index.html b/pyalchemybiz/public/index.html
deleted file mode 100644
index 98183c1..0000000
--- a/pyalchemybiz/public/index.html
+++ /dev/null
@@ -1,108 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-   "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-  <title>Pylons Default Page</title>
-  <style>
-    body { background-color: #fff; color: #333; }
-
-    body, p {
-      font-family: verdana, arial, helvetica, sans-serif;
-      font-size:   12px;
-      line-height: 18px;
-    }
-    pre {
-      background-color: #eee;
-      padding: 10px;
-      font-size: 11px;
-      line-height: 13px;
-    }
-
-    a { color: #000; }
-    a:visited { color: #666; }
-    a:hover { color: #fff; background-color:#000; }
-  </style>
-</head>
-<body>
-
-<h1>Welcome to your Pylons Web Application</h1>
-
-<h2>Weren't expecting to see this page?</h2>
-
-<p>The <tt>pyalchemybiz/public/</tt> directory is searched for static files
- <i>before</i> your controllers are run. Remove this file (<tt>pyalchemybiz/public/index.html</tt>)
-  and edit the routes in <tt>pyalchemybiz/config/routing.py</tt> to point the
-  <a href="/">root path</a> to a 'hello' controller we'll create below:
-  <pre> map.connect('', controller='hello', action='index')</pre>
-</p>
-
-<h2>Getting Started</h2>
-<p>You're now ready to start creating your own web application. To create a 'hello' controller,
-  run the following command in your project's root directory: 
-<pre>
-pyalchemybiz$ paster controller hello
-</pre>
-
-  This generates the following the following code in <tt>pyalchemybiz/controllers/hello.py</tt>:
-<pre>
-import logging
-
-from pyalchemybiz.lib.base import *
-
-log = logging.getLogger(__name__)
-
-class HelloController(BaseController):
-
-    def index(self):
-        # Return a rendered template
-        #   return render('/some/template.mako)
-        # or, Return a response
-        return 'Hello World'
-</pre>
-</p>
-<p>This controller simply prints out 'Hello World' to the browser. Pylons' default routes
-  automatically set up this controller to respond at the <a href="/hello">/hello</a> URL.
-  With the additional route described above, this controller will also respond at the
-  <a href="/">root path</a>.
-</p>
-
-<h3>Using a template</h3>
-<p>To call a template and do something a little more complex, this following example
-   shows how to print out some request information from a
-  <a href="http://www.makotemplates.org">Mako</a> template.
-</p>
-<p>Create a <tt>serverinfo.mako</tt> file in your project's <tt>pyalchemybiz/templates/</tt>
-  directory with the following contents:
-</p>  
-<pre>
-&lt;h2&gt;
-Server info for ${request.host}
-&lt;/h2&gt;
-
-&lt;p&gt;
-The URL you called: ${h.url_for()}
-&lt;/p&gt;
-
-&lt;p&gt;
-The name you set: ${c.name}
-&lt;/p&gt;
-
-&lt;p&gt;The WSGI environ:&lt;br /&gt;
-&lt;pre&gt;${c.pretty_environ}&lt;/pre&gt;
-&lt;/p&gt;
-</pre>
-
-Then add the following to your 'hello' controller class:
-<pre>
-    def serverinfo(self):
-        import cgi
-        import pprint
-        c.pretty_environ = cgi.escape(pprint.pformat(request.environ))
-        c.name = 'The Black Knight'
-        return render('/serverinfo.mako')
-</pre>
-
-You can now view the page at: <tt><a href="/hello/serverinfo">/hello/serverinfo</a></tt>
-</p>
-</body>
-</html>
diff --git a/pyalchemybiz/templates/base.mako b/pyalchemybiz/templates/base.mako
index ed0c538..f9b2739 100644
--- a/pyalchemybiz/templates/base.mako
+++ b/pyalchemybiz/templates/base.mako
@@ -13,7 +13,7 @@
       <p class="footer">
         Return to the
         ${h.link_to('FrontPage',
-            h.url_for(action="index"))}
+            h.url_for(controller="index", action="index"))}
       </p>
     </div>
   </body>
diff --git a/pyalchemybiz/templates/index.mako b/pyalchemybiz/templates/index.mako
new file mode 100644
index 0000000..24b60ec
--- /dev/null
+++ b/pyalchemybiz/templates/index.mako
@@ -0,0 +1,3 @@
+<%inherit file="base.mako" />
+
+${h.link_to('customers', h.url_for(controller="customer", action="index"))}
\ No newline at end of file
diff --git a/pyalchemybiz/tests/functional/test_index.py b/pyalchemybiz/tests/functional/test_index.py
new file mode 100644
index 0000000..e1b07cb
--- /dev/null
+++ b/pyalchemybiz/tests/functional/test_index.py
@@ -0,0 +1,7 @@
+from pyalchemybiz.tests import *
+
+class TestIndexController(TestController):
+
+    def test_index(self):
+        response = self.app.get(url_for(controller='index'))
+        # Test response...
diff --git a/setup.py b/setup.py
index c6d0429..ce20d15 100755
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,8 @@ setup(
     author='Jan Dittberner',
     author_email='jan@dittberner.info',
     url='http://www.dittberner.info/projects/pyalchemybiz',
-    install_requires=["Pylons>=0.9.6.2", "SQLAlchemy>=0.4"],
+    install_requires=["Pylons>=0.9.6.2", "SQLAlchemy>=0.4.7",
+                      "sqlalchemy-migrate>=0.4.5"],
     packages=find_packages(exclude=['ez_setup']),
     include_package_data=True,
     test_suite='nose.collector',
diff --git a/test.ini b/test.ini
index 9d3ed61..7bb9ce4 100644
--- a/test.ini
+++ b/test.ini
@@ -19,3 +19,6 @@ port = 5000
 use = config:development.ini
 
 # Add additional test specific configuration options as necessary.
+sqlalchemy.default.url = sqlite:///%(here)s/pyalchemybiz-test.db
+sqlalchemy.default.echo = true
+