-# Version: $Id$
-#
-# This file is part of pyalchemybiz
-from sqlalchemy import *
-
-def create_schema(metadata):
- """Create the database schema for products."""
- product_table = Table(
- 'product', metadata,
- Column('product_id', Integer, primary_key=True),
- Column('name', String(100), nullable=False),
- Column('description', String(4096), nullable=False),
- Column('product_type', Integer, nullable=False)
- )
- product_table.create()
diff --git a/pyalchemybiz/public/index.html b/pyalchemybiz/public/index.html
new file mode 100644
index 0000000..98183c1
--- /dev/null
+++ b/pyalchemybiz/public/index.html
@@ -0,0 +1,108 @@
+
+
+
+ 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
new file mode 100644
index 0000000..ed0c538
--- /dev/null
+++ b/pyalchemybiz/templates/base.mako
@@ -0,0 +1,20 @@
+
+
+
+ PyAlchemyBiz
+ ${h.stylesheet_link_tag('/pyalchemybiz.css')}
+ ${h.javascript_include_tag(
+ '/javascripts/pyalchemybiz.js', builtins=True)}
+
+
+
+ ${next.body()}\
+
+
+
+
diff --git a/pyalchemybiz/templates/customer.mako b/pyalchemybiz/templates/customer.mako
new file mode 100644
index 0000000..8aefd56
--- /dev/null
+++ b/pyalchemybiz/templates/customer.mako
@@ -0,0 +1,9 @@
+<%inherit file="base.mako" />
+
+Hallo
+
+
+% for customer in c.customers:
+ - ${customer.firstname} ${customer.lastname} [${h.link_to('edit', h.url_for(id=customer.id, action="edit"))}]
+% endfor
+
diff --git a/pyalchemybiz/tests/__init__.py b/pyalchemybiz/tests/__init__.py
new file mode 100644
index 0000000..91ff2e7
--- /dev/null
+++ b/pyalchemybiz/tests/__init__.py
@@ -0,0 +1,40 @@
+"""Pylons application test package
+
+When the test runner finds and executes tests within this directory,
+this file will be loaded to setup the test environment.
+
+It registers the root directory of the project in sys.path and
+pkg_resources, in case the project hasn't been installed with
+setuptools. It also initializes the application via websetup (paster
+setup-app) with the project's test.ini configuration file.
+"""
+import os
+import sys
+from unittest import TestCase
+
+import pkg_resources
+import paste.fixture
+import paste.script.appinstall
+from paste.deploy import loadapp
+from routes import url_for
+
+__all__ = ['url_for', 'TestController']
+
+here_dir = os.path.dirname(os.path.abspath(__file__))
+conf_dir = os.path.dirname(os.path.dirname(here_dir))
+
+sys.path.insert(0, conf_dir)
+pkg_resources.working_set.add_entry(conf_dir)
+pkg_resources.require('Paste')
+pkg_resources.require('PasteScript')
+
+test_file = os.path.join(conf_dir, 'test.ini')
+cmd = paste.script.appinstall.SetupCommand('setup-app')
+cmd.run([test_file])
+
+class TestController(TestCase):
+
+ def __init__(self, *args, **kwargs):
+ wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
+ self.app = paste.fixture.TestApp(wsgiapp)
+ TestCase.__init__(self, *args, **kwargs)
diff --git a/pyalchemybiz/tests/functional/__init__.py b/pyalchemybiz/tests/functional/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pyalchemybiz/tests/functional/test_customer.py b/pyalchemybiz/tests/functional/test_customer.py
new file mode 100644
index 0000000..5a96361
--- /dev/null
+++ b/pyalchemybiz/tests/functional/test_customer.py
@@ -0,0 +1,7 @@
+from pyalchemybiz.tests import *
+
+class TestCustomerController(TestController):
+
+ def test_index(self):
+ response = self.app.get(url_for(controller='customer'))
+ # Test response...
diff --git a/pyalchemybiz/tests/test_models.py b/pyalchemybiz/tests/test_models.py
new file mode 100644
index 0000000..e69de29
diff --git a/pyalchemybiz/websetup.py b/pyalchemybiz/websetup.py
new file mode 100644
index 0000000..5504807
--- /dev/null
+++ b/pyalchemybiz/websetup.py
@@ -0,0 +1,22 @@
+"""Setup the pyalchemybiz application"""
+import logging
+
+from paste.deploy import appconfig
+from pylons import config
+
+from pyalchemybiz.config.environment import load_environment
+
+log = logging.getLogger(__name__)
+
+def setup_config(command, filename, section, vars):
+ """Place any commands to setup pyalchemybiz here"""
+ conf = appconfig('config:' + filename)
+ load_environment(conf.global_conf, conf.local_conf)
+
+ # Populate the DB on 'paster setup-app'
+ import pyalchemybiz.model as model
+
+ log.info("Setting up database connectivity...")
+ log.info("Creating tables...")
+ model.meta.metadata.create_all(bind=model.meta.engine)
+ log.info("Successfully set up.")
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..60ab224
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,59 @@
+[egg_info]
+tag_build = dev
+tag_svn_revision = true
+
+[easy_install]
+find_links = http://www.pylonshq.com/download/
+
+[pudge]
+theme = pythonpaste.org
+
+# Add extra doc files here with spaces between them
+docs = docs/index.txt
+
+# Doc Settings
+doc_base = docs/
+dest = docs/html
+
+# Add extra modules here separated with commas
+modules = pyalchemybiz
+title = Pyalchemybiz
+organization = Pylons
+
+# Highlight code-block sections with Pygments
+highlighter = pygments
+
+# Optionally add extra links
+#organization_url = http://pylonshq.com/
+#trac_url = http://pylonshq.com/project
+settings = no_about=true
+
+# Optionally add extra settings
+# link1=/community/ Community
+# link2=/download/ Download
+
+[publish]
+doc-dir=docs/html
+make-dirs=1
+
+# Babel configuration
+[compile_catalog]
+domain = pyalchemybiz
+directory = pyalchemybiz/i18n
+statistics = true
+
+[extract_messages]
+add_comments = TRANSLATORS:
+output_file = pyalchemybiz/i18n/pyalchemybiz.pot
+width = 80
+
+[init_catalog]
+domain = pyalchemybiz
+input_file = pyalchemybiz/i18n/pyalchemybiz.pot
+output_dir = pyalchemybiz/i18n
+
+[update_catalog]
+domain = pyalchemybiz
+input_file = pyalchemybiz/i18n/pyalchemybiz.pot
+output_dir = pyalchemybiz/i18n
+previous = true
diff --git a/setup.py b/setup.py
index 57f6141..c6d0429 100755
--- a/setup.py
+++ b/setup.py
@@ -1,19 +1,31 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# Author: Jan Dittberner
-# Version: $Id$
-#
-# This file is part of pyalchemybiz
-#
-from setuptools import setup
-setup(name='pyalchemybiz',
- description='Python SQLAlchemy Business',
- version='0.1dev',
- author='Jan Dittberner',
- author_email='jan@dittberner.info',
- url='http://www.dittberner.info/projects/pyalchemybiz/',
- packages=['pyalchemybiz'],
- install_requires=['sqlalchemy >= 0.3.10'],
- license='GPL'
- )
+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='pyalchemybiz',
+ version="0.1",
+ description='python based small business suite.',
+ 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"],
+ packages=find_packages(exclude=['ez_setup']),
+ include_package_data=True,
+ test_suite='nose.collector',
+ package_data={'pyalchemybiz': ['i18n/*/LC_MESSAGES/*.mo']},
+ #message_extractors = {'pyalchemybiz': [
+ # ('**.py', 'python', None),
+ # ('templates/**.mako', 'mako', None),
+ # ('public/**', 'ignore', None)]},
+ entry_points="""
+ [paste.app_factory]
+ main = pyalchemybiz.config.middleware:make_app
+
+ [paste.app_install]
+ main = pylons.util:PylonsInstaller
+ """,
+)
diff --git a/test.ini b/test.ini
new file mode 100644
index 0000000..9d3ed61
--- /dev/null
+++ b/test.ini
@@ -0,0 +1,21 @@
+#
+# pyalchemybiz - Pylons 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@yourdomain.com
+smtp_server = localhost
+error_email_from = paste@localhost
+
+[server:main]
+use = egg:Paste#http
+host = 0.0.0.0
+port = 5000
+
+[app:main]
+use = config:development.ini
+
+# Add additional test specific configuration options as necessary.