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
This commit is contained in:
parent
554276ed23
commit
ab91d92af3
14 changed files with 52 additions and 213 deletions
|
@ -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()
|
||||
|
||||
|
|
@ -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' ')
|
||||
__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()
|
||||
|
||||
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
pyalchemybiz/tests/functional/__init__.py
|
||||
pyalchemybiz/tests/functional/test_customer.py
|
|
@ -1 +1,3 @@
|
|||
Pylons>=0.9.6.2
|
||||
Pylons>=0.9.6.2
|
||||
SQLAlchemy>=0.4.7
|
||||
sqlalchemy-migrate>=0.4.5
|
|
@ -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')
|
||||
|
||||
|
|
13
pyalchemybiz/controllers/index.py
Normal file
13
pyalchemybiz/controllers/index.py
Normal file
|
@ -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')
|
|
@ -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>
|
||||
<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>
|
||||
</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>
|
|
@ -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>
|
||||
|
|
3
pyalchemybiz/templates/index.mako
Normal file
3
pyalchemybiz/templates/index.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
<%inherit file="base.mako" />
|
||||
|
||||
${h.link_to('customers', h.url_for(controller="customer", action="index"))}
|
7
pyalchemybiz/tests/functional/test_index.py
Normal file
7
pyalchemybiz/tests/functional/test_index.py
Normal file
|
@ -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...
|
3
setup.py
3
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',
|
||||
|
|
3
test.ini
3
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue