From ab91d92af32aed77469fafbb581feb07239b7a60 Mon Sep 17 00:00:00 2001 From: Jan Dittberner 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'\n\n \n PyAlchemyBiz\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 \n \n
\n ') - # SOURCE LINE 12 - __M_writer(unicode(next.body())) - __M_writer(u'') - # SOURCE LINE 13 - __M_writer(u' \n
\n \n\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

Hallo

\n\n\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 @@ - - - - Pylons Default Page - - - - -

Welcome to your Pylons Web Application

- -

Weren't expecting to see this page?

- -

The pyalchemybiz/public/ directory is searched for static files - before your controllers are run. Remove this file (pyalchemybiz/public/index.html) - and edit the routes in pyalchemybiz/config/routing.py to point the - root path to a 'hello' controller we'll create below: -

 map.connect('', controller='hello', action='index')
-

- -

Getting Started

-

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: -

-pyalchemybiz$ paster controller hello
-
- - This generates the following the following code in pyalchemybiz/controllers/hello.py: -
-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'
-
-

-

This controller simply prints out 'Hello World' to the browser. Pylons' default routes - automatically set up this controller to respond at the /hello URL. - With the additional route described above, this controller will also respond at the - root path. -

- -

Using a template

-

To call a template and do something a little more complex, this following example - shows how to print out some request information from a - Mako template. -

-

Create a serverinfo.mako file in your project's pyalchemybiz/templates/ - directory with the following contents: -

-
-<h2>
-Server info for ${request.host}
-</h2>
-
-<p>
-The URL you called: ${h.url_for()}
-</p>
-
-<p>
-The name you set: ${c.name}
-</p>
-
-<p>The WSGI environ:<br />
-<pre>${c.pretty_environ}</pre>
-</p>
-
- -Then add the following to your 'hello' controller class: -
-    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')
-
- -You can now view the page at: /hello/serverinfo -

- - 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 @@ 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 +