I am just starting Python web development and have chosen Bottle as my framework of choice.
I am trying to have a project structure that is modular, as I can have a βmainβ application with modules built around it, where these modules can be turned on / off during installation (or βon the flyβ if possible ... not sure , how would I install it).
My "main" class is as follows:
from bottle import Bottle, route, run from bottle import error from bottle import jinja2_view as view from core import core app = Bottle() app.mount('/demo', core)
My "subproject" (i.e. module) is as follows:
from bottle import Bottle, route, run from bottle import error from bottle import jinja2_view as view app = Bottle() @app.route('/demo') @view('demographic') def greet(name='None', yob='None'): return dict(name=name, yob=yob) @error(404) def error404(error): return 'Nothing here, sorry'
When I go to http://localhost:5000/demo
in my browser, it shows error 500. Exit from the bottle server:
localhost - - [24/Jun/2012 15:51:27] "GET / HTTP/1.1" 404 720 localhost - - [24/Jun/2012 15:51:27] "GET /favicon.ico HTTP/1.1" 404 742 localhost - - [24/Jun/2012 15:51:27] "GET /favicon.ico HTTP/1.1" 404 742 Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/bottle-0.10.9-py2.7.egg/bottle.py", line 737, in _handle return route.call(**args) File "/usr/local/lib/python2.7/dist-packages/bottle-0.10.9-py2.7.egg/bottle.py", line 582, in mountpoint rs.body = itertools.chain(rs.body, app(request.environ, start_response)) TypeError: 'module' object is not callable
Folder structure:
index.py views (folder) |-->hello_template.tpl core (folder) |-->core.py |-->__init__.py |-->views (folder) |--|-->demographic.tpl
I have no idea what I'm doing (wrong) :)
Does anyone know how to do this / should be done?
Thanks!